gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 254C 19JavaScript 81371 Definiciones

⎇ 72a1d81325e63c351a9bcbf07427e676cbe938c4 benches/generated/absolute_layout_within_border.rs Rust · 121 líneas · 5.0 KB Historia Quién tocó qué crudo

rename stretch to stretch2 79aa44fa4 · elbaro ·

1pub fn compute() {
2    let mut stretch = stretch2::Stretch::new();
3    let node0 = stretch
4        .new_node(
5            stretch2::style::Style {
6                position_type: stretch2::style::PositionType::Absolute,
7                size: stretch2::geometry::Size {
8                    width: stretch2::style::Dimension::Points(50f32),
9                    height: stretch2::style::Dimension::Points(50f32),
10                    ..Default::default()
11                },
12                position: stretch2::geometry::Rect {
13                    start: stretch2::style::Dimension::Points(0f32),
14                    top: stretch2::style::Dimension::Points(0f32),
15                    ..Default::default()
16                },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node1 = stretch
23        .new_node(
24            stretch2::style::Style {
25                position_type: stretch2::style::PositionType::Absolute,
26                size: stretch2::geometry::Size {
27                    width: stretch2::style::Dimension::Points(50f32),
28                    height: stretch2::style::Dimension::Points(50f32),
29                    ..Default::default()
30                },
31                position: stretch2::geometry::Rect {
32                    end: stretch2::style::Dimension::Points(0f32),
33                    bottom: stretch2::style::Dimension::Points(0f32),
34                    ..Default::default()
35                },
36                ..Default::default()
37            },
38            &[],
39        )
40        .unwrap();
41    let node2 = stretch
42        .new_node(
43            stretch2::style::Style {
44                position_type: stretch2::style::PositionType::Absolute,
45                size: stretch2::geometry::Size {
46                    width: stretch2::style::Dimension::Points(50f32),
47                    height: stretch2::style::Dimension::Points(50f32),
48                    ..Default::default()
49                },
50                margin: stretch2::geometry::Rect {
51                    start: stretch2::style::Dimension::Points(10f32),
52                    end: stretch2::style::Dimension::Points(10f32),
53                    top: stretch2::style::Dimension::Points(10f32),
54                    bottom: stretch2::style::Dimension::Points(10f32),
55                    ..Default::default()
56                },
57                position: stretch2::geometry::Rect {
58                    start: stretch2::style::Dimension::Points(0f32),
59                    top: stretch2::style::Dimension::Points(0f32),
60                    ..Default::default()
61                },
62                ..Default::default()
63            },
64            &[],
65        )
66        .unwrap();
67    let node3 = stretch
68        .new_node(
69            stretch2::style::Style {
70                position_type: stretch2::style::PositionType::Absolute,
71                size: stretch2::geometry::Size {
72                    width: stretch2::style::Dimension::Points(50f32),
73                    height: stretch2::style::Dimension::Points(50f32),
74                    ..Default::default()
75                },
76                margin: stretch2::geometry::Rect {
77                    start: stretch2::style::Dimension::Points(10f32),
78                    end: stretch2::style::Dimension::Points(10f32),
79                    top: stretch2::style::Dimension::Points(10f32),
80                    bottom: stretch2::style::Dimension::Points(10f32),
81                    ..Default::default()
82                },
83                position: stretch2::geometry::Rect {
84                    end: stretch2::style::Dimension::Points(0f32),
85                    bottom: stretch2::style::Dimension::Points(0f32),
86                    ..Default::default()
87                },
88                ..Default::default()
89            },
90            &[],
91        )
92        .unwrap();
93    let node = stretch
94        .new_node(
95            stretch2::style::Style {
96                size: stretch2::geometry::Size {
97                    width: stretch2::style::Dimension::Points(100f32),
98                    height: stretch2::style::Dimension::Points(100f32),
99                    ..Default::default()
100                },
101                padding: stretch2::geometry::Rect {
102                    start: stretch2::style::Dimension::Points(10f32),
103                    end: stretch2::style::Dimension::Points(10f32),
104                    top: stretch2::style::Dimension::Points(10f32),
105                    bottom: stretch2::style::Dimension::Points(10f32),
106                    ..Default::default()
107                },
108                border: stretch2::geometry::Rect {
109                    start: stretch2::style::Dimension::Points(10f32),
110                    end: stretch2::style::Dimension::Points(10f32),
111                    top: stretch2::style::Dimension::Points(10f32),
112                    bottom: stretch2::style::Dimension::Points(10f32),
113                    ..Default::default()
114                },
115                ..Default::default()
116            },
117            &[node0, node1, node2, node3],
118        )
119        .unwrap();
120    stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
121}