do_line(3)

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

πŸ’« do_line(3) β€” the Allegro manual, but make it cute πŸ’«

okay bestie, welcome to the Allegro manual, page do_line(3). this is the Allegro game programming library, and we're about to learn how to make a line go brrr across your screen. no cap. πŸ¦‹


✨ NAME ✨

do_line β€” Calculates all the points along a line. Allegro game programming library. πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

void do_line(BITMAP *bmp, int x1, y1, x2, y2, int d, void (*proc)(BITMAP
*bmp, int x, int y, int d));

πŸ’… DESCRIPTION πŸ’…

so what this does is: it calculates all the points along a line, going from point (x1, y1) to (x2, y2), and for each one it calls the function you hand it. that's it. that's the whole vibe. 🌈

your function gets passed:

  • a copy of the bmp parameter πŸ’–
  • the x and y position ⭐
  • a copy of the d parameter ✨

which means it is suitable for use with putpixel(). it's giving "perfect little callback" energy, fr fr. 🫢

here's an example, because obviously we're not leaving you hanging:

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

and then you'd call it like this:

do_line(screen, 0, 0, SCREEN_W-1, SCREEN_H-2,
        dust_strength, draw_dust_particle);

look at that. dust particles. main character energy. πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€


bestie reminder: d gets passed as a copy to your callback, so don't go expecting to mutate the original through it. that's just how it is. πŸ’€

okay that's the whole page, you ate it, periodt. this was Allegro version 4.4.3, do_line(3), and honestly? iconic. go draw something pretty. πŸŽ€πŸ’œπŸ§š

πŸ“¦ where this page comes from