Grid part 1

This commit is contained in:
Synthasmagoria 2026-07-22 11:48:24 +02:00
commit 60622ccca5
3 changed files with 164 additions and 12 deletions

View file

@ -136,3 +136,35 @@ rect_get_br :: proc {
@(private="file") irect2_get_br :: proc(rect: irect2) -> iv2 {
return {rect.x + rect.width, rect.y + rect.height}
}
rect_get_size :: proc {
rect2_get_size,
irect2_get_size,
}
@(private="file") rect2_get_size :: proc(rect: rect2) -> v2 {
return {rect.width, rect.height}
}
@(private="file") irect2_get_size :: proc(rect: irect2) -> iv2 {
return {rect.width, rect.height}
}
/// ## LINEAR ALGEBRA ## ///
matrix3_translate2 :: proc "contextless" (translation: v2) -> mat3 {
return {
1.0, 0.0, translation.x,
0.0, 1.0, translation.y,
0.0, 0.0, 1.0,
}
}
matrix3_transform_v2 :: proc(m: mat3, v: v2) -> v2 {
return (m * v3{**v, 1.0}).xy
}
matrix3_transform_rect2 :: proc(m: mat3, r: rect2) -> rect2 {
tl := m * v3{r.x, r.y, 1.0}
br := m * v3{r.x + r.width, r.y + r.height, 1.0}
return {**tl.xy, **(br - tl).xy}
}