package toffee

  1. Overview
  2. Docs

Module Toffee_geometry.RectfSource

Rectangles of floats.

A t holds four edges in floats, flat, as Sizef.t holds a size: layout computes its padding, borders and margins as ts. Rect remains for rectangles of other values, such as lengths or optional floats.

Sourcetype t = {
  1. left : float;
  2. right : float;
  3. top : float;
  4. bottom : float;
}

Four edges.

Constants and creation

Sourceval zero : t

zero has every edge 0.0.

Sourceval make : left:float -> right:float -> top:float -> bottom:float -> t

make ~left ~right ~top ~bottom is { left; right; top; bottom }.

Sourceval all : float -> t

all value has every edge value.

Arithmetic

Sourceval add : t -> t -> t

add a b adds a and b edge by edge.

Sourceval (+) : t -> t -> t

a + b is add a b.

Sourceval horizontal_axis_sum : t -> float

horizontal_axis_sum rect is rect.left +. rect.right.

Sourceval vertical_axis_sum : t -> float

vertical_axis_sum rect is rect.top +. rect.bottom.

Sourceval sum_axes : t -> Sizef.t

sum_axes rect is the horizontal sum as the width and the vertical sum as the height.

Sourceval grid_axis_sum : Absolute_axis.t -> t -> float

grid_axis_sum axis rect is the horizontal sum for Horizontal and the vertical sum for Vertical.

Conversions

Sourceval of_rect : float Rect.t -> t

of_rect rect has the edges of rect.

Sourceval to_rect : t -> float Rect.t

to_rect rect has the edges of rect.

Comparison and formatting

Sourceval equal : t -> t -> bool

equal a b is true iff every edge is an equal float.

Sourceval compare : t -> t -> int

compare a b orders by left, right, top, then bottom, as Float.compare.

Sourceval to_string : t -> string

to_string rect is a readable representation of rect.

Sourceval pp : Format.formatter -> t -> unit

pp formats a rectangle as to_string.