mach: atlas: add UV calculation helper
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
0a3a76fdcd
commit
3d27836318
1 changed files with 21 additions and 0 deletions
|
|
@ -82,6 +82,27 @@ pub const Region = extern struct {
|
|||
y: u32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
|
||||
pub const UV = extern struct {
|
||||
x: f32,
|
||||
y: f32,
|
||||
width: f32,
|
||||
height: f32,
|
||||
};
|
||||
|
||||
pub inline fn calculateUV(r: Region, size: u32) UV {
|
||||
var uv = UV{
|
||||
.x = @floatFromInt(r.x),
|
||||
.y = @floatFromInt(r.y),
|
||||
.width = @floatFromInt(r.width),
|
||||
.height = @floatFromInt(r.height),
|
||||
};
|
||||
uv.x /= @floatFromInt(size);
|
||||
uv.y /= @floatFromInt(size);
|
||||
uv.width /= @floatFromInt(size);
|
||||
uv.height /= @floatFromInt(size);
|
||||
return uv;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn init(alloc: Allocator, size: u32, format: Format) !Atlas {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue