89 lines
2.2 KiB
Zig
89 lines
2.2 KiB
Zig
const std = @import("std");
|
|
pub const c = @import("c.zig").c;
|
|
|
|
pub const Point = extern struct {
|
|
x: c_int,
|
|
y: c_int,
|
|
};
|
|
|
|
pub const FPoint = extern struct {
|
|
x: f32,
|
|
y: f32,
|
|
};
|
|
|
|
pub const Rect = extern struct {
|
|
x: c_int,
|
|
y: c_int,
|
|
w: c_int,
|
|
h: c_int,
|
|
};
|
|
|
|
pub const FRect = extern struct {
|
|
x: f32,
|
|
y: f32,
|
|
w: f32,
|
|
h: f32,
|
|
};
|
|
|
|
pub inline fn hasRectIntersection(A: *const Rect, B: *const Rect) bool {
|
|
return c.SDL_HasRectIntersection(@ptrCast(A), @ptrCast(B));
|
|
}
|
|
|
|
pub inline fn getRectIntersection(A: *const Rect, B: *const Rect, result: ?*Rect) bool {
|
|
return c.SDL_GetRectIntersection(@ptrCast(A), @ptrCast(B), result);
|
|
}
|
|
|
|
pub inline fn getRectUnion(A: *const Rect, B: *const Rect, result: ?*Rect) bool {
|
|
return c.SDL_GetRectUnion(@ptrCast(A), @ptrCast(B), result);
|
|
}
|
|
|
|
pub inline fn getRectEnclosingPoints(
|
|
points: *const Point,
|
|
count: c_int,
|
|
clip: *const Rect,
|
|
result: ?*Rect,
|
|
) bool {
|
|
return c.SDL_GetRectEnclosingPoints(@ptrCast(points), count, @ptrCast(clip), result);
|
|
}
|
|
|
|
pub inline fn getRectAndLineIntersection(
|
|
rect: *const Rect,
|
|
X1: *c_int,
|
|
Y1: *c_int,
|
|
X2: *c_int,
|
|
Y2: *c_int,
|
|
) bool {
|
|
return c.SDL_GetRectAndLineIntersection(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2));
|
|
}
|
|
|
|
pub inline fn hasRectIntersectionFloat(A: *const FRect, B: *const FRect) bool {
|
|
return c.SDL_HasRectIntersectionFloat(@ptrCast(A), @ptrCast(B));
|
|
}
|
|
|
|
pub inline fn getRectIntersectionFloat(A: *const FRect, B: *const FRect, result: ?*FRect) bool {
|
|
return c.SDL_GetRectIntersectionFloat(@ptrCast(A), @ptrCast(B), result);
|
|
}
|
|
|
|
pub inline fn getRectUnionFloat(A: *const FRect, B: *const FRect, result: ?*FRect) bool {
|
|
return c.SDL_GetRectUnionFloat(@ptrCast(A), @ptrCast(B), result);
|
|
}
|
|
|
|
pub inline fn getRectEnclosingPointsFloat(
|
|
points: *const FPoint,
|
|
count: c_int,
|
|
clip: *const FRect,
|
|
result: ?*FRect,
|
|
) bool {
|
|
return c.SDL_GetRectEnclosingPointsFloat(@ptrCast(points), count, @ptrCast(clip), result);
|
|
}
|
|
|
|
pub inline fn getRectAndLineIntersectionFloat(
|
|
rect: *const FRect,
|
|
X1: *f32,
|
|
Y1: *f32,
|
|
X2: *f32,
|
|
Y2: *f32,
|
|
) bool {
|
|
return c.SDL_GetRectAndLineIntersectionFloat(@ptrCast(rect), @ptrCast(X1), @ptrCast(Y1), @ptrCast(X2), @ptrCast(Y2));
|
|
}
|