Open kornelski opened 1 month ago
I'm a bit confused by the use-case, can you provide an example using concrete types since your example uses generic types but then also does as
casts so I'm assuming it's not generic?
How about this?
use rgb::{HetPixel, Pixel, Rgba};
fn main() {
let px: Rgba<u8> = Rgba {
r: 0,
g: 10,
b: 10,
a: 255,
};
let px = px.map(f32::from);
let px = px.map_colors(|c| c * px.a);
print!("{px}");
}
map_rgb
onRGBA<T, A>
uses aFrom
for theA
type to make it matchT
, allowing code likepx.map_colors(|c| c as f32 * px.a as f32)
to just work and update alpha.map_colors
is just for the colors, and results in an annoyingRGBA<f32, u8>
.https://docs.rs/rgb/0.8.90-alpha.2/rgb/trait.HetPixel.html#tymethod.map_colors
Should it also convert alpha? Should there be another method?