polygon(3)

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

✨ polygon(3) ✨

okay bestie, pop off, we're in the Allegro manual and this page is all about polygon β€” the lil function that draws a filled polygon πŸ’… it lives in the Allegro game programming library, and honestly? iconic.


🌸 NAME 🌸

polygon β€” draws a filled polygon πŸŽ€ Allegro game programming library, periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void polygon(BITMAP *bmp, int vertices, const int *points, int color);

πŸ’– DESCRIPTION πŸ’–

so the way that this works is: polygon draws a filled polygon with an arbitrary number of corners. no cap, arbitrary β€” you can have as many corners as your heart desires 🫢

you pass it the number of vertices, plus an array containing a series of x, y points. and bestie, listen β€” that array holds a total of vertices*2 values, because every single corner is two lil numbers living their best life side by side πŸ₯°

example, since i know you're a visual learner:

int points[12] = { 50, 50,   100, 100,  100, 150,
                   50, 200,  0,   150,  0,   100 };
...
clear_to_color(screen, makecol(255, 255, 255));
polygon(screen, 6, points, makecol(0, 0, 0));

see how it's giving six vertices and twelve whole numbers? that's the vertices*2 math doing its thing ✨ clear the screen to white, then draw a black filled hexagon on top. slay.


🌈 SEE ALSO 🌈


aaaand that's the whole page, babe πŸŽ€ this was Allegro, version 4.4.3, and polygon(3) said what it said β€” go draw something cute, mwah πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from