Module Clpr.Rect64

An axis-aligned rectangle used bounding box computations and quick rectangular clipping (boolean intersection) operations. (see Paths64.rect_clip)

type t

Construction and Conversion

val make : l:int64 -> t:int64 -> r:int64 -> b:int64 -> t

make ~l ~t ~r ~b

Create an axis-aligned rectangle with the bounds left, top, right, and bottom.

val of_pts : Point64.t -> Point64.t -> t

of_pts a b

Create an axis-aligned bounding box (rectangle) that contains the points a and b.

val as_path : t -> {path64}6

as_path t

Obtain a path describing the perimeter of the rectangle t.

Access

val width : t -> int64

width t

Obtain the width of the rectangle t.

val height : t -> int64

height t

Obtain the height of the rectangle t.

val midpoint : t -> Point64.t

midpoint t

Obtain the midpoint of the rectangle t.

Transformations

val scale : float -> t -> t

scale t s

Scale the rectangle t by the factor s.

Geometry

val contains_pt : t -> Point64.t -> bool

contains_pt t p

Determine whether the point p lies within the rectangle t.

val contains_rect : t -> t -> bool

contains_rect a b

Determine whether the rectangle a fully contains the rectangle b.

val is_empty : t -> bool

is_empty t

Check whether the rectangle t has an area of zero.

val intersects : t -> t -> bool

intersects a b

Determine whether the rectangles a and b intersect.