Added bound helper (#40)
Co-authored-by: Zachary Levy <zachary@sunforge.is> Reviewed-on: #40
This commit was merged in pull request #40.
This commit is contained in:
@@ -857,6 +857,15 @@ needs_transform :: #force_inline proc(origin: Vec2, rotation: f32) -> bool {
|
|||||||
// ----- Anchors ------------
|
// ----- 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.
|
// Return Vec2 pixel offsets for use as the `origin` parameter of draw calls.
|
||||||
// Composable with normal vector +/- arithmetic.
|
// Composable with normal vector +/- arithmetic.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user