Added bound helper #40

Merged
zack merged 1 commits from draw-bound into master 2026-06-29 19:04:57 +00:00
+9
View File
@@ -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.
//