Fix 1px wide gaps between adjacent UI nodes (#374)
1use taffy::prelude::*;
2
3#[test]
4fn rounding_doesnt_leave_gaps() {
5 // First create an instance of Taffy
6 let mut taffy = Taffy::new();
7
8 let w_square = Size { width: points(100.3), height: points(100.3) };
9 let child_a = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
10 let child_b = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
11
12 let root_node = taffy
13 .new_with_children(
14 Style {
15 size: Size { width: points(963.3333), height: points(1000.) },
16 justify_content: Some(JustifyContent::Center),
17 ..Default::default()
18 },
19 &[child_a, child_b],
20 )
21 .unwrap();
22
23 taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap();
24
25 let layout_a = taffy.layout(child_a).unwrap();
26 let layout_b = taffy.layout(child_b).unwrap();
27 taffy::debug::print_tree(&taffy, root_node);
28 assert_eq!(layout_a.location.x + layout_a.size.width, layout_b.location.x);
29}