draw_character_ex(3)
π draw_character_ex β NAME
ok so bestie, this is draw_character_ex, page three of the Allegro manual, and it Draws non transparent pixels of the sprite with a color. it lives in the Allegro game programming library, which is the whole vibe. π
β¨ SYNOPSIS β¨
#include <allegro.h>
void draw_character_ex(BITMAP *bmp, BITMAP *sprite, int x, int y, color,
bg);
no cap, that's the whole signature. yes the color and bg params forgot their types in the listing, but that's literally how it's written, so we're keeping it exactly like that. π«Ά
πΈ DESCRIPTION πΈ
okay so here's the tea. draw_character_ex takes a copy of the sprite bitmap and draws it onto the destination bitmap at the position you asked for β but with a glow-up. the transparent pixels get drawn in the background color instead (or just skipped entirely if the background color is -1), and every other pixel β all the not-transparent ones β gets set to the color you specified. it's giving silhouette mode. it's giving stencil. obsessed. π₯
and how do we know which pixels are "transparent"?? bestie, the rules are:
- in 256-color modes, a transparent pixel is marked by a zero
- in truecolor data, it's bright pink (which means maximum red and blue, and zero green) π
β οΈ IMPORTANT, no cap: the sprite must be an 8-bit image, even if the destination is a truecolor bitmap. that's the rule, don't fight it. π
Example time, because examples slay:
BITMAP *logo;
...
/* Draw the logo silhouette in red. */
draw_character_ex(screen, logo, SCREEN_W / 2, SCREEN_H / 2,
makecol(255, 0, 0), -1);
look at that. logo silhouette. dead center. red. -1 for the bg so the transparent pixels just dip out entirely instead of getting painted over. main character energy fr fr. π
π¦ SEE ALSO π¦
go read those too, iykyk, they're part of the same little friend group π
and that's the whole page!! this was Allegro, version 4.4.3, and it's the draw_character_ex(3) page β ty for coming to my ted talk, go draw something cute, mwah πβ¨π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms