do_ellipse(3alleg4)

πŸ’– do_ellipse β€” Allegro manual πŸ’–

okay bestie, pull up a chair, we're gonna talk about one of those quiet little legends of the Allegro 4 library. this one lives in the Allegro game programming library, and it's about to make your ellipse go brrr. πŸ¦‹


✨ NAME ✨

do_ellipse β€” Calculates all the points in an ellipse. Allegro game programming library.


🌸 SYNOPSIS 🌸

#include <allegro.h>

void do_ellipse(BITMAP *bmp, int x, int y, int rx, ry, int d, void
(*proc)(BITMAP *bmp, int x, int y, int d));

πŸ’… DESCRIPTION πŸ’…

so basically, do_ellipse crunches every single point that makes up an ellipse, like, all of them, and it does it around the point (x, y) with radius rx and ry. and the way it hands them to you?? it calls the function you supply, once per point. iconic behaviour, honestly. πŸ‘‘

for each point it calls that function with a copy of the bmp parameter, the x and y position, and a copy of the d parameter. which means β€” and this is the part where you go "ohhh" β€” it's suitable for use with putpixel(). that's the whole point, bestie. you draw the pixels yourself inside your callback.

Example, because we love a demo:

void draw_explosion_ring(BITMAP *bmp, int x, int y, int d)
{
   ...
}

   do_ellipse(screen, SCREEN_W/2, SCREEN_H/2,
             SCREEN_H/16, SCREEN_H/32, flame_color,
             draw_explosion_ring);

not me using it to make an explosion ring in the dead centre of the screen 😭 the radius is a sixteenth of the screen height and a thirty-second of the screen height, and flame_color just gets yeeted through to your function as d. no cap.

fr fr: your callback needs to match that signature exactly β€” BITMAP *bmp, int x, int y, int d β€” otherwise this whole vibe check fails.

🫢 SEE ALSO 🫢


and that's the whole page, bestie!! this was the Allegro manual, version 4.4.3, and the page is dated do_ellipse(3alleg4) β€” go forth and draw your little rings of flame. i'm obsessed. periodt. πŸ’œβœ¨