API ReferenceLayout Values
Color
Compact sRGBA8 color with linear, HSL, and HSV conversions.
use incular::prelude::*;
fn main() {
let accent = Color::rgba(30, 32, 40, 255);
println!("accent: {:?}", accent.to_linear_rgba());
let back = Color::from_linear_rgba(accent.to_linear_rgba());
println!("round-trip: {:?}", back == accent);
println!("white: {:?}", Color::WHITE.to_hsl());
}Swatches with a linear round-trip — copy, paste, and run:
use incular::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let accent = Color::rgba(30, 32, 40, 255);
let back = Color::from_linear_rgba(accent.to_linear_rgba());
let app = Application::new(move |_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
Row::builder()
.spacing(8.0)
.children(Vec::<Widget>::from([
Container::new()
.color(Color::WHITE)
.width(80.0)
.height(80.0).into(),
Container::new()
.color(accent)
.width(80.0)
.height(80.0).into(),
Container::new()
.color(back)
.width(80.0)
.height(80.0).into(),
]))
.build(),
)
.build()
.into()
})?;
incular::run(app)?;
Ok(())
}| Member | Kind | Notes |
|---|---|---|
TRANSPARENT | Constant | rgba(0,0,0,0) |
WHITE | Constant | rgba(255,255,255,255) |
BLACK | Constant | rgba(0,0,0,255) |
rgba(r,g,b,a) | Constructor | const fn, u8 channels |
to_linear_rgba | Conversion | Gamma-correct blending math |
from_linear_rgba | Conversion | Sanitizes NaN, clamps 0..=1 |
to_hsl / to_hsv | Conversion | Via HslColor / HsvColor |
Per-channel Lerp with clamped t. Used by Container,
TextStyle, and Paint.
Related: Brush.