tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 227Rust 7TOML 3CSS 1307 Sutichaykuna

⎇ b91874d4e34ecc9054b468a338ffcae6f61a1b4a benches/generated/padding_center_child.rs Rust · 35 siq'ikuna · 1.4 KB Ñawpa willay Pi imata llamkarqan ch'uya

Implement CSS Grid (#205) 6fd2c6bcb · Nico Burns ·

1pub fn compute() {
2    #[allow(unused_imports)]
3    use taffy::prelude::*;
4    let mut taffy = taffy::Taffy::new();
5    let node0 = taffy
6        .new_leaf(taffy::style::Style {
7            size: taffy::geometry::Size {
8                width: taffy::style::Dimension::Points(10f32),
9                height: taffy::style::Dimension::Points(10f32),
10            },
11            ..Default::default()
12        })
13        .unwrap();
14    let node = taffy
15        .new_with_children(
16            taffy::style::Style {
17                align_items: Some(taffy::style::AlignItems::Center),
18                justify_content: Some(taffy::style::JustifyContent::Center),
19                size: taffy::geometry::Size {
20                    width: taffy::style::Dimension::Points(100f32),
21                    height: taffy::style::Dimension::Points(100f32),
22                },
23                padding: taffy::geometry::Rect {
24                    left: taffy::style::LengthPercentage::Points(10f32),
25                    right: taffy::style::LengthPercentage::Points(20f32),
26                    top: taffy::style::LengthPercentage::Points(10f32),
27                    bottom: taffy::style::LengthPercentage::Points(20f32),
28                },
29                ..Default::default()
30            },
31            &[node0],
32        )
33        .unwrap();
34    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
35}