tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Definitions

⎇ 0.1.x benches/generated/margin_auto_bottom_and_top_justify_center.rs Rust · 49 lines · 1.6 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(50f32),
8                    height: taffy::style::Dimension::Points(50f32),
9                    ..Default::default()
10                },
11                margin: taffy::geometry::Rect {
12                    top: taffy::style::Dimension::Auto,
13                    bottom: taffy::style::Dimension::Auto,
14                    ..Default::default()
15                },
16                ..Default::default()
17            },
18            &[],
19        )
20        .unwrap();
21    let node1 = taffy
22        .new_node(
23            taffy::style::Style {
24                size: taffy::geometry::Size {
25                    width: taffy::style::Dimension::Points(50f32),
26                    height: taffy::style::Dimension::Points(50f32),
27                    ..Default::default()
28                },
29                ..Default::default()
30            },
31            &[],
32        )
33        .unwrap();
34    let node = taffy
35        .new_node(
36            taffy::style::Style {
37                justify_content: taffy::style::JustifyContent::Center,
38                size: taffy::geometry::Size {
39                    width: taffy::style::Dimension::Points(200f32),
40                    height: taffy::style::Dimension::Points(200f32),
41                    ..Default::default()
42                },
43                ..Default::default()
44            },
45            &[node0, node1],
46        )
47        .unwrap();
48    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
49}