You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
map_rgb on RGBA<T, A> uses a From for the A type to make it match T, allowing code like px.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 annoying RGBA<f32, u8>.
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};fnmain(){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?
The text was updated successfully, but these errors were encountered: