arc(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’« arc(3) πŸ’«

okay bestie, welcome to the Allegro manual β€” today's main character is arc, and she draws circles. well, parts of circles. iconic behaviour, honestly.


🌸 NAME 🌸

arc β€” draws a circular arc. it's giving Allegro game programming library, and it's giving geometry. πŸŽ€


✨ SYNOPSIS ✨

#include <allegro.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: arc draws a circular arc with centre x, y and radius r, going in an anticlockwise direction, starting from the angle a1 and ending when it reaches a2. πŸ’…

those angle values are in 16.16 fixed point format, and the math is lowkey cute:

  • 256 equals a full circle 🌈
  • 64 equals a right angle ⭐
  • and so on, you get it

Zero is to the right of the centre point, and larger values rotate anticlockwise from there. no cap. πŸ”₯

example time, because seeing it is believing:

/* 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));

not me using itofix() to turn regular numbers into fixed point so the arc actually knows what angle I mean 😭 that's the whole trick, bestie.


πŸ‘‘ SEE ALSO πŸ‘‘


psa: angles are fixed point, not plain ints. if your arc is acting weird, that's why. itofix() is your friend, fr fr. 🫢

and that's the whole page, bestie β€” this was Allegro, version 4.4.3, and yeah it's still filed under arc(3). go draw something pretty. πŸ’–πŸ§šβœ¨

πŸ“¦ where this page comes from