,,,
This commit is contained in:
11
ui/types.sx
11
ui/types.sx
@@ -4,7 +4,7 @@
|
|||||||
Point :: struct {
|
Point :: struct {
|
||||||
x, y: f32;
|
x, y: f32;
|
||||||
|
|
||||||
zero :: () -> Point { Point.{ x = 0.0, y = 0.0 }; }
|
zero :: () -> Point => .{ x = 0.0, y = 0.0 };
|
||||||
|
|
||||||
add :: (self: Point, b: Point) -> Point {
|
add :: (self: Point, b: Point) -> Point {
|
||||||
Point.{ x = self.x + b.x, y = self.y + b.y };
|
Point.{ x = self.x + b.x, y = self.y + b.y };
|
||||||
@@ -28,7 +28,7 @@ Point :: struct {
|
|||||||
Size :: struct {
|
Size :: struct {
|
||||||
width, height: f32;
|
width, height: f32;
|
||||||
|
|
||||||
zero :: () -> Size { Size.{ width = 0.0, height = 0.0 }; }
|
zero :: () -> Size => .{ width = 0.0, height = 0.0 };
|
||||||
|
|
||||||
contains :: (self: Size, point: Point) -> bool {
|
contains :: (self: Size, point: Point) -> bool {
|
||||||
point.x >= 0.0 and point.x <= self.width and point.y >= 0.0 and point.y <= self.height;
|
point.x >= 0.0 and point.x <= self.width and point.y >= 0.0 and point.y <= self.height;
|
||||||
@@ -58,8 +58,9 @@ Frame :: struct {
|
|||||||
y1 := max(self.origin.y, other.origin.y);
|
y1 := max(self.origin.y, other.origin.y);
|
||||||
x2 := min(self.max_x(), other.max_x());
|
x2 := min(self.max_x(), other.max_x());
|
||||||
y2 := min(self.max_y(), other.max_y());
|
y2 := min(self.max_y(), other.max_y());
|
||||||
if x2 <= x1 or y2 <= y1 then Frame.zero()
|
if x2 <= x1 or y2 <= y1
|
||||||
else Frame.make(x1, y1, x2 - x1, y2 - y1);
|
then .zero()
|
||||||
|
else .make(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inset :: (self: Frame, insets: EdgeInsets) -> Frame {
|
inset :: (self: Frame, insets: EdgeInsets) -> Frame {
|
||||||
@@ -114,7 +115,7 @@ Color :: struct {
|
|||||||
r = xx (self.r + (b.r - self.r) * t),
|
r = xx (self.r + (b.r - self.r) * t),
|
||||||
g = xx (self.g + (b.g - self.g) * t),
|
g = xx (self.g + (b.g - self.g) * t),
|
||||||
b = xx (self.b + (b.b - self.b) * t),
|
b = xx (self.b + (b.b - self.b) * t),
|
||||||
a = xx (self.a + (b.a - self.a) * t)
|
a = xx (self.a + (b.a - self.a) * t),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user