Yesterday, I posted a demonstration of alpha blending "transparency" on the TI-84+CE in the SAX chat. Now, I have made the code available online here so that you guys can use it.

`set_alpha_color` sets the color to be used in the blending operation.
`alpha_mask_sprite` draws a masking sprite using the alpha color. It pays attention to the global transparent index.
Thanks for not only putting this together, but for sharing it with the community as well! For fun, I took a look at the code, and I have a comment and a question:
  • I notice you use some inscrutable decimal constants like 31744 and 992. When I convert them to hex (0x7c00 to mask bits 14-10 and 0x03e0 to mask bits 9-5 respectively), it becomes much clearer. I suggest using the hex equivalents, and perhaps adding more commenting for code you publish. More comments and more documentation are always better, especially when code isn't inherently self-documenting.
  • From tracing it out, it looks like it averages the original color and the overlaid color, producing effectively 50% transparency. Have you given any thought to being able to set an arbitrary transparency percentage, or even more challenging, allowing per-pixel transparency values?
I have thought about percentage-based transparency, which would be easy to implement, but I don't think per-pixel transparency values are going to be feasible with the current display mode I'm using for this project (8bpp).

I've seen something about 16bpp in CEMU. I'm thinking that if I use 16bpp, then I could probably accomplish something close to (if not the same as) per-pixel transparency on the CE.

Edit: 24bpp is impractical.
I have updated it to support multiple alpha colors!

Code:
set_alpha_colors
Allows you to divide the palette even further for more alpha colors. Unfortunately, running it more than once without variation will abruptly change the alpha color for some unknown reason. Try to run it once each time you want to change the color.


Code:
multi_alpha_mask_sprite
displays alpha sprites that use multiple alpha colors. The indexes in the sprite dictate which alpha color it will use. Currently, it functions similarly to `alpha_mask_sprite` when used with 1 alpha color as input without issues.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement