pub struct Luma {
pub lightness: Ratio,
pub alpha: Ratio,
}Expand description
A color in the grayscale (D65 gray) color space.
The color.luma constructor in Typst.
See the Typst documentation.
§Examples
use typwire::{Luma, Ratio, initiate_protocol};
initiate_protocol!();
#[typwire::export]
fn lightness(color: Luma) -> Result<Ratio, String> {
Ok(color.lightness)
}Fields§
§lightness: RatioThe lightness component of the color.
alpha: RatioThe alpha (transparency) component of the color.
Implementations§
Source§impl Luma
impl Luma
Sourcepub const fn new(lightness: Ratio, alpha: Ratio) -> Self
pub const fn new(lightness: Ratio, alpha: Ratio) -> Self
Creates a new Luma color with the given lightness and alpha.
§Examples
use typwire::{Luma, Ratio};
let luma = Luma::new(Ratio::new(0.5), Ratio::new(1.0));
assert_eq!(luma.lightness, Ratio::new(0.5));
assert_eq!(luma.alpha, Ratio::new(1.0));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Luma
impl<'de> Deserialize<'de> for Luma
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Luma
impl Typwire for Luma
Auto Trait Implementations§
impl Forget for Luma
impl Freeze for Luma
impl Move for Luma
impl RefUnwindSafe for Luma
impl Send for Luma
impl Sync for Luma
impl Unpin for Luma
impl UnsafeUnpin for Luma
impl UnwindSafe for Luma
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more