arc(3alleg4)

πŸ’– arc β€” the one where we draw a cute lil' slice of a circle πŸ’–

okay bestie, gather round, we're doing the Allegro manual today and this one is a certified classic. it's a function from the Allegro game programming library, and it's giving "I just want a curved line, please." ✨


✨ NAME ✨

arc β€” draws a circular arc. from the Allegro game programming library, obviously. πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);

like. look at her. so simple. so powerful. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: arc draws a circular arc with its centre sitting at x, y, and a radius of r. 🫢

it goes in an anticlockwise direction, starting from the angle a1 and stopping the moment it reaches a2. iconic behaviour, no notes.

now the angles β€” this is the part where you gotta pay attention, bestie, because these values are in 16.16 fixed point format 😭 and the scale is:

  • 256 = a full circle (yes, a whole one, she's complete)
  • 64 = a right angle
  • etc. you get the pattern, i believe in you

and for the vibe check on direction: zero is to the right of the centre point, and larger values rotate anticlockwise from there. so the numbers grow as you spin counter-clockwise. periodt. πŸ’«

here's the example, and i'm keeping it EXACTLY as it is because we do not touch the code:

/* Draw a black arc from 4 to 1 o'clock. */
arc(screen, SCREEN_W/2, SCREEN_H/2,
    itofix(-21), itofix(43), 50, makecol(0, 0, 0));

like she literally draws a black arc from 4 to 1 o'clock and that's just... art. main character energy fr fr. πŸ”₯

quick reminder bestie: the angles are 16.16 fixed point, so use itofix() on your numbers unless you enjoy chaos πŸ’€

πŸ’œ SEE ALSO πŸ’œ

go read these next, they're the whole friend group:


and that's the whole page, bestie!! πŸ₯³ this was Allegro version 4.4.3 talking, so if your arc is acting up, check your version and check your fixed point math, and you'll be slaying in no time. ily, go draw something pretty πŸŒˆπŸ‘‘πŸ’–