Update ui and minor utils cleanup
This commit is contained in:
parent
31422d9592
commit
1f4be3fdd3
2 changed files with 56 additions and 53 deletions
57
utils.odin
57
utils.odin
|
|
@ -91,11 +91,19 @@ enum_to_raygui_options_string :: proc($T: typeid, allocator: mem.Allocator) -> c
|
|||
|
||||
|
||||
/// ### RECTANGLES ### ///
|
||||
rect_from :: proc {
|
||||
rect2_from_v2,
|
||||
irect2_from_iv2,
|
||||
rect_translate :: proc {rect2_translate, irect2_translate}
|
||||
|
||||
@(private="file") rect2_translate :: proc "contextless" (rect: rect2, translation: v2) -> rect2 {
|
||||
return {rect.x + translation.x, rect.y + translation.y, rect.width, rect.height}
|
||||
}
|
||||
|
||||
@(private="file") irect2_translate :: proc "contextless" (rect: irect2, translation: iv2) -> irect2 {
|
||||
return {rect.x + translation.x, rect.y + translation.y, rect.width, rect.height}
|
||||
}
|
||||
|
||||
|
||||
rect_from :: proc {rect2_from_v2, irect2_from_iv2}
|
||||
|
||||
@(private="file") rect2_from_v2 :: proc "contextless" (position, size: v2) -> rect2 {
|
||||
return {position.x, position.y, size.x, size.y}
|
||||
}
|
||||
|
|
@ -104,10 +112,8 @@ rect_from :: proc {
|
|||
return {position.x, position.y, size.x, size.y}
|
||||
}
|
||||
|
||||
rect_scale :: proc{
|
||||
rect2_scale,
|
||||
irect2_scale,
|
||||
}
|
||||
|
||||
rect_scale :: proc{rect2_scale, irect2_scale}
|
||||
|
||||
@(private="file") rect2_scale :: proc "contextless" (rect: rect2, scalar: f32) -> rect2 {
|
||||
return {rect.x * scalar, rect.y * scalar, rect.width * scalar, rect.height * scalar}
|
||||
|
|
@ -117,12 +123,8 @@ rect_scale :: proc{
|
|||
return {rect.x * scalar, rect.y * scalar, rect.width * scalar, rect.height * scalar}
|
||||
}
|
||||
|
||||
rect_grow :: proc {
|
||||
rect2_grow,
|
||||
rect2_grow_v2,
|
||||
irect2_grow,
|
||||
rect2_grow_iv2,
|
||||
}
|
||||
|
||||
rect_grow :: proc {rect2_grow, rect2_grow_v2, irect2_grow, rect2_grow_iv2}
|
||||
|
||||
@(private="file") rect2_grow :: proc "contextless" (rect: rect2, grow: f32) -> rect2 {
|
||||
return {rect.x - grow, rect.y - grow, rect.width + grow * 2.0, rect.height + grow * 2.0}
|
||||
|
|
@ -141,10 +143,7 @@ rect_grow :: proc {
|
|||
}
|
||||
|
||||
|
||||
rect_from_area :: proc {
|
||||
rect_from_area_v2,
|
||||
rect_from_area_iv2,
|
||||
}
|
||||
rect_from_area :: proc {rect_from_area_v2, rect_from_area_iv2}
|
||||
|
||||
@(private="file") rect_from_area_v2 :: proc "contextless" (start, end: v2) -> rect2 {
|
||||
tl := linalg.min(start, end)
|
||||
|
|
@ -156,10 +155,8 @@ rect_from_area :: proc {
|
|||
return {**tl, **(linalg.max(start, end) - tl)}
|
||||
}
|
||||
|
||||
rect_from_corners :: proc {
|
||||
rect2_from_corners,
|
||||
irect2_from_corners,
|
||||
}
|
||||
|
||||
rect_from_corners :: proc {rect2_from_corners, irect2_from_corners}
|
||||
|
||||
@(private="file") rect2_from_corners :: proc "contextless" (tl, tr, br, bl: v2) -> rect2 {
|
||||
top_left := linalg.min(linalg.min(tl, tr, br), bl)
|
||||
|
|
@ -173,10 +170,8 @@ rect_from_corners :: proc {
|
|||
return {**top_left, **(bottom_right - top_left)}
|
||||
}
|
||||
|
||||
rect_get_tl :: proc {
|
||||
rect2_get_tl,
|
||||
irect2_get_tl,
|
||||
}
|
||||
|
||||
rect_get_tl :: proc {rect2_get_tl, irect2_get_tl}
|
||||
|
||||
@(private="file") rect2_get_tl :: proc(rect: rect2) -> v2 {
|
||||
return {rect.x, rect.y}
|
||||
|
|
@ -186,10 +181,8 @@ rect_get_tl :: proc {
|
|||
return {rect.x, rect.y}
|
||||
}
|
||||
|
||||
rect_get_br :: proc {
|
||||
rect2_get_br,
|
||||
irect2_get_br,
|
||||
}
|
||||
|
||||
rect_get_br :: proc {rect2_get_br, irect2_get_br}
|
||||
|
||||
@(private="file") rect2_get_br :: proc(rect: rect2) -> v2 {
|
||||
return {rect.x + rect.width, rect.y + rect.height}
|
||||
|
|
@ -199,10 +192,8 @@ rect_get_br :: proc {
|
|||
return {rect.x + rect.width, rect.y + rect.height}
|
||||
}
|
||||
|
||||
rect_get_size :: proc {
|
||||
rect2_get_size,
|
||||
irect2_get_size,
|
||||
}
|
||||
|
||||
rect_get_size :: proc {rect2_get_size, irect2_get_size}
|
||||
|
||||
@(private="file") rect2_get_size :: proc(rect: rect2) -> v2 {
|
||||
return {rect.width, rect.height}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue