tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 10TOML 3CSS 1350 Sutichaykuna

⎇ 7a9692ba74b0b382e7cc3b212355be20abfd6b0e examples/basic.rs Rust · 24 siq'ikuna · 762 B Ñawpa willay Pi imata llamkarqan ch'uya

index: fix formatting and warnings 7a9692ba7 · msiglreith ·

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