package toffee
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/toffee.geometry/Geometry/Rect/index.html
Module Geometry.RectSource
Axis-aligned rectangles representing margins, padding, borders, or insets.
A rectangle is defined by four edges: left, right, top, and bottom. Each edge value can represent coordinates, spacing, or offsets depending on context.
In CSS layout, rectangles primarily represent spacing properties like padding and margin, where each edge specifies the amount of space on that side.
Type
'a t represents a rectangle with four edges.
The type parameter 'a allows rectangles of different value types:
float tfor concrete measurementsDimension.t tfor CSS dimension valuesLength_percentage.t tfor length or percentage values
Constants
Creation
make ~left ~right ~top ~bottom creates a rectangle.
Mapping Functions
map2 f r1 r2 applies f to corresponding edges of r1 and r2.
zip_size size f rect applies f to each edge with its corresponding dimension.
For left and right edges, f receives size.width as the second argument. For top and bottom edges, f receives size.height as the second argument.
Component Extraction
horizontal_components rect extracts the left and right edges as a line.
vertical_components rect extracts the top and bottom edges as a line.
Arithmetic Operations
Axis Sums
horizontal_axis_sum rect returns rect.left +. rect.right.
This computes total horizontal spacing, not the width of the rectangle.
vertical_axis_sum rect returns rect.top +. rect.bottom.
This computes total vertical spacing, not the height of the rectangle.
sum_axes rect returns both axis sums as a size.
Equivalent to {width = horizontal_axis_sum rect; height = vertical_axis_sum rect}.
grid_axis_sum axis rect returns the sum along axis.
Returns horizontal_axis_sum rect for Horizontal, vertical_axis_sum rect for Vertical.
Comparison and String Functions
compare cmp a b lexicographically compares a and b using cmp.
Edges are compared in order: left, right, top, bottom.
equal eq a b tests if a and b are equal using eq for each edge.
to_string f rect converts rect to a string representation using f for each edge.
pp f fmt rect prints rect to fmt using f for each edge.