/** C R E D I T Idea from: https://halt.software/p/rectcut-for-dead-simple-ui-layouts Code from: https://solarium.technology/ */ rcut_from_right :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_right_fixed (rect, rect.width * percentage); } rcut_from_left :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_left_fixed (rect, rect.width * percentage); } rcut_from_top :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_top_fixed (rect, rect.height * percentage); } rcut_from_bottom :: inline (using rect: *$T/interface Rectangle, percentage: float) -> T { return rcut_from_bottom_fixed (rect, rect.height * percentage); } rcut_from_right_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T { result := T.{ x + width - n, y, n, height }; width = max(width - n, 0); return result; } rcut_from_left_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T { result := T.{ x, y, n, height }; x += n; width = max(width - n, 0); return result; } rcut_from_top_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T { result := T.{ x, y, width, n }; y += n; height = max(height - n, 0); return result; } rcut_from_bottom_fixed :: inline (using rect: *$T/interface Rectangle, n: float) -> T { result := T.{ x, y + height - n, width, n }; height = max(height - n, 0); return result; } rcut_shrink :: inline (using rect: $T/interface Rectangle, n: float) -> T { return { x + n, y + n, width - n*2, height - n*2 }; }