tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definitions

⎇ 0.1.x benches/generated/padding_center_child.rs Rust · 39 lines · 1.4 KB History Who touched what raw

Rename sprawl to taffy (#134) 8936790d6 · Alice Cecile ·

1pub fn compute() {
2    let mut taffy = taffy::Taffy::new();
3    let node0 = taffy
4        .new_node(
5            taffy::style::Style {
6                size: taffy::geometry::Size {
7                    width: taffy::style::Dimension::Points(10f32),
8                    height: taffy::style::Dimension::Points(10f32),
9                    ..Default::default()
10                },
11                ..Default::default()
12            },
13            &[],
14        )
15        .unwrap();
16    let node = taffy
17        .new_node(
18            taffy::style::Style {
19                align_items: taffy::style::AlignItems::Center,
20                justify_content: taffy::style::JustifyContent::Center,
21                size: taffy::geometry::Size {
22                    width: taffy::style::Dimension::Points(100f32),
23                    height: taffy::style::Dimension::Points(100f32),
24                    ..Default::default()
25                },
26                padding: taffy::geometry::Rect {
27                    start: taffy::style::Dimension::Points(10f32),
28                    end: taffy::style::Dimension::Points(20f32),
29                    top: taffy::style::Dimension::Points(10f32),
30                    bottom: taffy::style::Dimension::Points(20f32),
31                    ..Default::default()
32                },
33                ..Default::default()
34            },
35            &[node0],
36        )
37        .unwrap();
38    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
39}