contains
Whether a point or a rectangle is inside a rectangle.
For a point (hit-testing), the left and top edges are inside and the right and bottom ones are not, so a point on the edge between two adjacent rectangles hits exactly one of them. A rectangle is inside when it does not stick out: it may touch any edge.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
r | Rect | The containing rectangle |
target | Point | Rect | A point, or a rectangle |
Returns
Section titled “Returns”boolean — true if target is inside r
Examples
Section titled “Examples”Hit-test a click
Section titled “Hit-test a click”Shared edges hit once: the right and bottom edges are outside.
Is a layer fully on screen?
Section titled “Is a layer fully on screen?”A rectangle is inside when it does not stick out.
Related Types
Section titled “Related Types”A point in 2D space.
An axis-aligned rectangle: its top-left corner and its size. Width and height are expected to be non-negative.
