draw_character_ex(3alleg4)

✨ draw_character_ex β€” bestie edition ✨

okay so this is a page from the Allegro manual (the 3alleg4 one, for the Allegro game programming library πŸ’–) and it's literally about drawing a sprite's non-transparent pixels in a color. silhhouette vibes. icon behavior. let's go 🫢


πŸ’… NAME

draw_character_ex β€” draws the non transparent pixels of the sprite with a color, bestie. it's giving Allegro game programming library. periodt.


🌸 SYNOPSIS

#include <allegro.h>

void draw_character_ex(BITMAP *bmp, BITMAP *sprite, int x, int y, color,
bg);

no cap, that's the whole thing πŸ‘‘


πŸ¦‹ DESCRIPTION

so what it does: it draws a copy of the sprite bitmap onto the destination bitmap at the position you specify, and here's the twist β€” it draws the transparent pixels in the background color (or just skips them entirely if the background color is -1), and it sets all the other pixels to the specified color. so like, the whole thing comes out as one flat color silhouette. main character energy, honestly 😭

how do you even mark transparent pixels, you ask? with a zero in 256-color modes, or bright pink for truecolor data (that's maximum red and blue, zero green β€” the iconic magenta situation πŸ’…).

⚠️ important bestie: the sprite must be an 8-bit image, even if the destination is a truecolor bitmap. no exceptions. the vibe check is strict on this one.

example, because we love a demonstration ✨:

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. centered logo, fully red, transparent pixels skipped. we ate πŸ”₯


πŸ‘€ SEE ALSO


and that's the whole page, babe πŸŽ€ this was draw_character_ex(3alleg4) from the Allegro manual, version 4.4.3 β€” go forth and silhouette responsibly, ily πŸ’œπŸ§š