tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definitions

⎇ a380b58cb0418ea3728af9a67d188410c6c10f7a benches/generated/child_min_max_width_flexing.rs Rust · 47 lines · 1.5 KB History Who touched what raw

Update all benchmarks to use the new API a380b58cb · David Flemström ·

1pub fn compute() {
2    let mut stretch = stretch::Stretch::new();
3    let node0 = stretch
4        .new_node(
5            stretch::style::Style {
6                flex_grow: 1f32,
7                flex_shrink: 0f32,
8                flex_basis: stretch::style::Dimension::Points(0f32),
9                min_size: stretch::geometry::Size {
10                    width: stretch::style::Dimension::Points(60f32),
11                    ..Default::default()
12                },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node1 = stretch
19        .new_node(
20            stretch::style::Style {
21                flex_grow: 1f32,
22                flex_shrink: 0f32,
23                flex_basis: stretch::style::Dimension::Percent(0.5f32),
24                max_size: stretch::geometry::Size {
25                    width: stretch::style::Dimension::Points(20f32),
26                    ..Default::default()
27                },
28                ..Default::default()
29            },
30            &[],
31        )
32        .unwrap();
33    let node = stretch
34        .new_node(
35            stretch::style::Style {
36                size: stretch::geometry::Size {
37                    width: stretch::style::Dimension::Points(120f32),
38                    height: stretch::style::Dimension::Points(50f32),
39                    ..Default::default()
40                },
41                ..Default::default()
42            },
43            &[node0, node1],
44        )
45        .unwrap();
46    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
47}