2024-02-11 20:00:06 -08:00
|
|
|
package sectr
|
|
|
|
|
|
|
|
import "core:encoding/json"
|
|
|
|
|
|
|
|
import rl "vendor:raylib"
|
|
|
|
|
2024-02-12 17:52:56 -08:00
|
|
|
// TODO(Ed) : I made this before doing Ryan's UI series. It was my initial attempt at a "frame"
|
|
|
|
// conceptually that I need as an Entity primitive for all my 2D primitives that I would lay out
|
|
|
|
// in either world (workspace) space or in screenspace (fixed ui space)
|
|
|
|
|
2024-02-11 20:00:06 -08:00
|
|
|
Box2 :: struct {
|
|
|
|
position : Vec2,
|
|
|
|
extent : Extents2,
|
2024-02-12 17:52:56 -08:00
|
|
|
color : Color,
|
|
|
|
layer : i32,
|
2024-02-11 20:00:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
box_size :: proc( box : ^ Box2 ) -> AreaSize {
|
|
|
|
return transmute(AreaSize) box.extent * 2.0
|
|
|
|
}
|
|
|
|
|
|
|
|
box_get_bounds :: proc( box : ^ Box2 ) -> Bounds2 {
|
|
|
|
top_left := box.position + Vec2 { -box.extent.x, box.extent.y }
|
|
|
|
bottom_right := box.position + Vec2 { box.extent.x, -box.extent.y }
|
|
|
|
return { top_left, bottom_right }
|
|
|
|
}
|
|
|
|
|
|
|
|
box_set_size :: proc( box : ^ Box2, size : AreaSize ) {
|
|
|
|
box.extent = transmute(Extents2) size * 0.5
|
|
|
|
}
|
|
|
|
|
2024-02-11 21:35:22 -08:00
|
|
|
// TODO(Ed) : Fix this up?
|
2024-02-23 06:36:23 -08:00
|
|
|
get_rl_rect :: proc( box : ^ Box2 ) -> rl.Rectangle {
|
2024-02-11 20:00:06 -08:00
|
|
|
rect : rl.Rectangle = {
|
|
|
|
x = box.position.x - box.extent.x,
|
|
|
|
y = box.position.y - box.extent.y,
|
|
|
|
width = box.extent.x * 2.0,
|
|
|
|
height = box.extent.y * 2.0,
|
|
|
|
}
|
|
|
|
return rect
|
|
|
|
}
|