Skip to content

@jsvision/ui / intersect

Function: intersect()

intersect(a, b): Rect

Defined in: ui/src/view/geometry.ts:28

Compute the overlapping region of two rects — the clip operation (a view rect ∩ its ancestor's clip). When the two do not overlap, the result has width/height of 0 (never negative), which downstream code treats as "draw nothing".

Parameters

a

Rect

First rect.

b

Rect

Second rect.

Returns

Rect

The intersection rect; zero-size when the inputs do not overlap.

Example

ts
import { intersect } from '@jsvision/ui';

intersect({ x: 0, y: 0, width: 10, height: 4 }, { x: 5, y: 1, width: 10, height: 10 });
// → { x: 5, y: 1, width: 5, height: 3 }