58 lines
1.0 KiB
Zig
58 lines
1.0 KiB
Zig
const Vec2i = @This();
|
|
|
|
const Recti = @import("Recti.zig");
|
|
const Vec2f = @import("Vec2f.zig");
|
|
const Layer = @import("../Layer.zig");
|
|
const Color = @import("../Color.zig");
|
|
const std = @import("std");
|
|
|
|
x: i32,
|
|
y: i32,
|
|
|
|
pub fn create(x: i32, y: i32) Vec2i {
|
|
return .{
|
|
.x = x,
|
|
.y = y,
|
|
};
|
|
}
|
|
|
|
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 fn add(self: Vec2i, other: Vec2i) Vec2i {
|
|
return Vec2i {
|
|
.x = self.x + other.x,
|
|
.y = self.y + other.y,
|
|
};
|
|
}
|
|
|
|
pub fn draw(self: *const Vec2i, radius: f32, layer: Layer, color: Color) void {
|
|
_ = self;
|
|
_ = radius;
|
|
_ = layer;
|
|
_ = color;
|
|
}
|
|
|
|
pub fn to_vec2f(self: *const Vec2i) Vec2f {
|
|
return Vec2f {
|
|
.x = @floatFromInt(self.x),
|
|
.y = @floatFromInt(self.y),
|
|
};
|
|
}
|
|
|
|
|
|
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);
|