0/** C R E D I T
1 Idea from: https://halt.software/p/rectcut-for-dead-simple-ui-layouts
2 Code from: https://solarium.technology/
3*/
6rcut_from_right :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_right_fixed (rect, rect.width * percentage); }
7rcut_from_left :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_left_fixed (rect, rect.width * percentage); }
8rcut_from_top :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_top_fixed (rect, rect.height * percentage); }
9rcut_from_bottom :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_bottom_fixed (rect, rect.height * percentage); }
11rcut_from_right_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T {
12 result := T.{ x + width - n, y, n, height };
13 width = max(width - n, 0);
14 return result;
15}
17rcut_from_left_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T {
18 result := T.{ x, y, n, height };
19 x += n;
20 width = max(width - n, 0);
21 return result;
22}
24rcut_from_top_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T {
25 result := T.{ x, y, width, n };
26 y += n;
27 height = max(height - n, 0);
28 return result;
29}
31rcut_from_bottom_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T {
32 result := T.{ x, y + height - n, width, n };
33 height = max(height - n, 0);
34 return result;
35}
37rcut_shrink :: inline (using rect: $T/interface Rectangle, n: float) -> T {
38 return { x + n, y + n, width - n*2, height - n*2 };
39}
index : binary-tree
---