UI module

intersect

procedureextensionexperimentalsince 0.31.0Source

The overlap of two rectangles (zero-sized when they do not touch).

Example↗
overlap := intersect(.{ 0, 0, 10, 10 }, .{ 5, 5, 10, 10 });
assert(overlap.x == 5 && overlap.w == 5 && overlap.h == 5);
assert(intersect(.{ 0, 0, 1, 1 }, .{ 5, 5, 1, 1 }).w == 0);
intersect :: (a: Rect, b: Rect) -> Rect

The overlap of two rectangles (zero-sized when they do not touch).

Parameters

a: Rect
the first rectangle.
b: Rect
the second rectangle.

Returns

Example↗
overlap := intersect(.{ 0, 0, 10, 10 }, .{ 5, 5, 10, 10 });
assert(overlap.x == 5 && overlap.w == 5 && overlap.h == 5);
assert(intersect(.{ 0, 0, 1, 1 }, .{ 5, 5, 1, 1 }).w == 0);

See also