Added bound helper #40
@@ -857,6 +857,15 @@ needs_transform :: #force_inline proc(origin: Vec2, rotation: f32) -> bool {
|
||||
// ----- Anchors ------------
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Translate `local` — a point relative to `bounds`'s top-left — into `bounds`'s own coordinate
|
||||
// space by offsetting it by the rectangle's origin. Unlike the anchor helpers above (which
|
||||
// return size-relative offsets and ignore `bounds.x`/`bounds.y`), this uses the rectangle's
|
||||
// position. Handy for drawing inside a sub-region whose rect you were handed — e.g. the
|
||||
// `bounds` passed to a `Custom_Draw` callback: `local_to_bounds(bounds, {cx, cy})`.
|
||||
bound :: #force_inline proc(bounds: Rectangle, local: Vec2) -> Vec2 {
|
||||
return {bounds.x + local.x, bounds.y + local.y}
|
||||
}
|
||||
|
||||
// Return Vec2 pixel offsets for use as the `origin` parameter of draw calls.
|
||||
// Composable with normal vector +/- arithmetic.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user