do_arc(3alleg4)

πŸ’– do_arc πŸ’–

okay bestie, you're in the Allegro manual, the game programming library, and this page is all about do_arc β€” the lil function that goes "hey, here's every single point on this arc, do whatever you want with them." ✨


✨ SYNOPSIS ✨

#include <allegro.h>

void do_arc(BITMAP *bmp, int x, int y, fixed a1, fixed a2, int r, int d,
void (*proc)(BITMAP *bmp, int x, int y, int d));

🌸 DESCRIPTION 🌸

So basically πŸ’… β€” do_arc calculates all the points in a circular arc around the point (x, y) with radius r, and for each one it calls the function you handed it. Obsessed, honestly.

That supplied function gets passed:

  • a copy of the bmp parameter
  • the x and y position
  • a copy of the d parameter

...which means it's literally perfect for pairing with putpixel(). 🫢

The arc gets plotted anticlockwise, starting from the angle a1 and ending when it reaches a2. Those values are in 16.16 fixed point format β€” where 256 equals a full circle, 64 a right angle, etc. Zero is to the right of the centre point, and larger values rotate anticlockwise from there. slay. πŸŽ€

Example, bestie:

   void draw_explosion_ring(BITMAP *bmp, int x, int y, int d)
   {
      ...
   }
      do_arc(screen, SCREEN_W/2, SCREEN_H/2,
          itofix(-21), itofix(43), 50, flame_color,
          draw_explosion_ring);

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole vibe, queen πŸ‘‘ this page lives in Allegro version 4.4.3, so if you're out here arcing your little heart out, that's the version you're doing it in. mwah πŸ’‹βœ¨πŸ’–