Skip to main content

with_alpha

Function with_alpha 

pub fn with_alpha(c: AlphaColor<Srgb>, alpha: u8) -> AlphaColor<Srgb>
Expand description

c with its alpha replaced by the 8-bit alpha (0 transparent, 255 opaque), keeping its 8-bit RGB.

use tilo_ui::paint::with_alpha;
use tilo_ui::vello::peniko::Color;
assert_eq!(
    with_alpha(Color::from_rgb8(10, 20, 30), 0x40),
    Color::from_rgba8(10, 20, 30, 0x40)
);