gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definitions

⎇ 4c14991d8cb32e0b8f87b0dde48035a1d493331d examples/basic.rs Rust · 23 lines · 705 B History Who touched what raw

added prelude + some refactoring 4c14991d8 · Adam Nemecek ·

1use stretch::prelude::*;
2
3fn main() -> Result<(), Error> {
4    let mut stretch = Stretch::new();
5    let child = stretch.new_node(
6        Style { size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto }, ..Default::default() },
7        &[],
8    )?;
9    let node = stretch.new_node(
10        Style {
11            size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) },
12            justify_content: JustifyContent::Center,
13            ..Default::default()
14        },
15        &[child],
16    )?;
17
18    stretch.compute_layout(node, Size::undefined())?;
19    println!("node: {:#?}", stretch.layout(node)?);
20    println!("child: {:#?}", stretch.layout(child)?);
21
22    Ok(())
23}