Gg.Box2
2D axis-aligned boxes.
type t = box2
The type for 2D boxes (rectangles).
dim
is the dimension of the boxes of type box2
.
type v = v2
The type for 2D vectors.
type p = p2
The type for 2D points.
type size = size2
The type for 2D sizes.
type m = m2
The type for matrices representing linear transformations of 2D space.
val empty : box2
empty
is the empty box.
val ox : box2 -> float
ox b
is V2.x (o b)
.
val oy : box2 -> float
oy b
is V2.y (o b)
.
val w : box2 -> float
w b
is Size2.w (size b)
.
val h : box2 -> float
h b
is Size2.h (size b)
.
val aspect : box2 -> float
aspect b
is Size2.aspect
(size b)
.
val zero : box2
zero
is a box whose origin and size is zero.
val unit : box2
unit
is the unit box which extends from zero to one in all dimensions.
val minx : box2 -> float
minx b
is V2.x (min b)
.
val miny : box2 -> float
miny b
is V2.y (min b)
.
max b
is the greatest point of b
(its size added to the origin).
Raises Invalid_argument
on empty
val maxx : box2 -> float
maxx b
is V2.x (max b)
.
val maxy : box2 -> float
maxy b
is V2.y (max b)
.
val midx : box2 -> float
midx b
is V2.x (mid b)
.
val midy : box2 -> float
midy b
is V2.y (mid b)
.
val area : box2 -> float
area b
is the surface area of b
.
inter b b'
is a box whose space is the intersection of S(b
) and S(b'
).
inset d b
is b
whose edges are inset in each dimension according to amounts in d
. Negative values in d
outset. If the size in dimension i
becomes negative it is clamped to 0
and the i
th coordinate of the mid point of b
is used for the i
th coordinate of the resulting box's origin. Returns empty
on empty
.
val is_pt : box2 -> bool
is_pt b
is true
iff b
is not empty
and its size is equal to 0 in every dimension.
val is_seg : box2 -> bool
is_seg b
is true
iff b
is not empty
and its size is equal to 0 in exactly one dimension.
equal_f eq b b'
tests b
and b'
like equal
but uses eq
to test floating point values.
compare_f cmp b b'
compares b
and b'
like compare
but uses cmp
to compare floating point values.
val pp : Stdlib.Format.formatter -> box2 -> unit
pp ppf b
prints a textual representation of b
on ppf
.