2024-08-21 15:57:18 -04:00
|
|
|
const Vec2i = @This();
|
|
|
|
|
|
2024-09-03 13:13:28 -04:00
|
|
|
const Recti = @import("Recti.zig");
|
|
|
|
|
|
2024-08-21 15:57:18 -04:00
|
|
|
x: i32,
|
|
|
|
|
y: i32,
|
|
|
|
|
|
2024-09-03 13:13:28 -04:00
|
|
|
pub fn create(x: i32, y: i32) Vec2i {
|
2024-08-21 15:57:18 -04:00
|
|
|
return .{
|
|
|
|
|
.x = x,
|
|
|
|
|
.y = y,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-03 13:13:28 -04:00
|
|
|
pub fn scale(self: *const Vec2i, s: i32) Vec2i {
|
|
|
|
|
return .{
|
|
|
|
|
.x = self.x * s,
|
|
|
|
|
.y = self.y * s
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn to_unit_recti(self: *const Vec2i) Recti {
|
|
|
|
|
return Recti.from_xywh(self.x, self.y, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub const ZERO = create(0, 0);
|
|
|
|
|
pub const ONE = create(1, 1);
|
|
|
|
|
pub const NORTH = create(0, -1);
|
|
|
|
|
pub const SOUTH = create(0, 1);
|
|
|
|
|
pub const EAST = create(1, 0);
|
|
|
|
|
pub const WEST = create(-1, 0);
|