QuantumBadger / Speedy2D

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Draw image and rectangular image with opacity control

superlou opened this issue · comments

For drawing most primitives, the opacity/alpha is controlled through an RGBA color. Is it possible to add opacity control to the draw_image and draw_rectangle_image... functions? Is that already supposed to be achieved using draw_rectangle_image_tinted and RGBA color of (1, 1, 1, opacity) instead? If that's the case, then new functions aren't needed. I wasn't sure if there's a speed impact of tinting vs. a simpler opacity control.

Is that already supposed to be achieved using draw_rectangle_image_tinted and RGBA color of (1, 1, 1, opacity) instead?

Yes this is correct. I think draw_rectangle_image_tinted should be the fastest way to do this -- the shader multiplies each pixel of the image by the tint colour, which includes the alpha value. The original draw_rectangle_image actually just calls draw_rectangle_image_tinted with a tint of Color::WHITE :)

That works great, thanks!