gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 497HTML 254C 19JavaScript 81329 Definiciones

⎇ dfdb5a21fc84b657c51b185abe30c54c19fb89b6 examples/basic.rs Rust · 23 líneas · 705 B Historia Quién tocó qué crudo

added prelude + some refactoring dfdb5a21f · 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}