SectrPrototype/code/frame.odin
Ed_ f76ba4e9ba Lots of stuff (Big ones are cam and frame initial features)
There is now a 2D camera in the workspace!
We have a basic 'Frame' definition. It doesn't have any interaction yet...

I started to define spacial math, mostly for doing conversion and getting a grounding on pixel/points/cm reference. The world space is in cm.
2024-02-10 03:40:53 -05:00

28 lines
643 B
Odin

package sectr
Frame :: struct {
position : Vec2,
width, height : f32,
color : Color
}
get_bounds :: proc( frame : ^ Frame ) -> Bounds2 {
half_width := frame.width / 2
half_height := frame.height / 2
bottom_left := Vec2 { -half_width, -half_height }
top_right := Vec2 { half_width, half_height }
return { bottom_left, top_right }
}
get_rect :: proc ( frame : ^ Frame ) -> Rectangle {
half_width := frame.width / 2
half_height := frame.height / 2
rect : Rectangle = {
x = frame.position.x - half_width,
y = frame.position.y - half_height,
width = frame.width,
height = frame.height,
}
return rect
}