draw_trans_rle_sprite(3alleg4)

✨ draw_trans_rle_sprite β€” bestie edition ✨

okay so you want a translucent RLE sprite on your screen?? say less πŸ’… this is from the Allegro game programming library (yes, the 3alleg4 manual, we're fancy here), and it's literally the see-through version of drawing an RLE sprite. slay.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

void draw_trans_rle_sprite(BITMAP *bmp, const RLE_SPRITE *sprite, int x,
int y);

that's it. that's the whole function signature. no cap. 🫢


🌸 DESCRIPTION 🌸

So this is the translucent version of draw_rle_sprite() β€” like, it does the same thing but the sprite is see-through. ghost vibes. πŸ‘» If you wanna know more about the transparency side of things, go read the description of draw_trans_sprite().

⚠️ IMPORTANT BESTIE, LISTEN: you can only use this after you've set up the color mapping table (for 256-color modes) or the blender functions (for truecolor modes). Don't skip this step, it's giving "crashing at 3am" energy and we don't want that. 😭

Normally the bitmap and the sprite have to be in the same color depth β€” that's just the rules, sorry. BUT as a special lil exception: you can draw 32-bit RGBA format sprites onto any hicolor or truecolor bitmap, as long as you call set_alpha_blender() first. iconic behavior honestly. ✨

Here's the example, straight from the source, keep it exact bestie:

/* Some one time initialisation code. */
COLOR_MAP global_trans_table;
create_trans_table(&global_trans_table, my_palette,
                   128, 128, 128, NULL);
...
if (get_color_depth() == 8)
   color_map = &global_trans_table;
else
   set_trans_blender(128, 128, 128, 128);

draw_trans_rle_sprite(buffer, rle_ghost_sprite, x, y);

see how the ... is just hanging out there? that's the "the rest of your code goes here" moment. main character pause. πŸŽ€


πŸ‘‘ SEE ALSO πŸ‘‘

the girlies you should also go read, fr fr:


okay that's the whole page, you ate that πŸ“ this was Allegro, version 4.4.3, and it's the draw_trans_rle_sprite(3alleg4) manual page β€” go forth and draw translucent sprites like the icon you are. bye bestie πŸ’œβœ¨