wasm4 icon indicating copy to clipboard operation
wasm4 copied to clipboard

Add alpha blit functions for sprites

Open tjpalmer opened this issue 3 years ago • 5 comments

The alpha could be 1bpp, and both 1bpp and 2bpp color versions would be nice.

tjpalmer avatar Nov 29 '21 14:11 tjpalmer

Isn't this already supported just be using one of the 4 colors as the alpha channel and then setting DRAW_COLORS appropriately? (ie, 2 bit allows for easy 3 colors + 1 alpha channel)

Or are you asking for 4 colors PLUS an alpha channel?

joshgoebel avatar Dec 22 '21 05:12 joshgoebel

I was meaning a separate alpha channel entirely, although maybe it's a rare enough need that people wouldn't really use. And of course, people can already make their own functions for this.

But I also don't see an option for color 0 (or whatever) as transparent in the current blit (or text) function. Maybe ok again, since people can also do this on their own if they want. Or maybe nice to have directly in the standard api.

tjpalmer avatar Dec 22 '21 13:12 tjpalmer

And yes, this was motivated by gingerBill's demo in the old discord.

tjpalmer avatar Dec 22 '21 13:12 tjpalmer

But I also don't see an option for color 0 (or whatever) as transparent in the current blit (or text) function.

It's not color 0, it's ANY color... just set DRAW_COLOR for that palette color to 0 and it's treated as transparent - this is documented somewhere - try it. So one can make any one of the 4 colors (or all 4) transparent... that eliminates the need for alpha UNLESS you need it JUST for masking of arbitrary boundaries separately from color... ie, 4 colors plus transparency... ie "this black pixel is opaque" AND "this black pixel is transparent".

I'm not sure that edge case is worth adding to the API with our philosophy on keeping things minimal.

joshgoebel avatar Dec 23 '21 03:12 joshgoebel

Awesome. Thanks for the info! The separate alpha mask could still be fun, but yeah, maybe let people do that on their own if they want it. If folks want to close this issue, that's fine.

tjpalmer avatar Dec 23 '21 03:12 tjpalmer