Ed_
f76ba4e9ba
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.
28 lines
643 B
Odin
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
|
|
}
|