Geometry.RectSourceAxis-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.
'a t represents a rectangle with four edges.
The type parameter 'a allows rectangles of different value types:
float t for concrete measurementsDimension.t t for CSS dimension valuesLength_percentage.t t for length or percentage valuesmake ~left ~right ~top ~bottom creates a rectangle.
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.
horizontal_components rect extracts the left and right edges as a line.
vertical_components rect extracts the top and bottom edges as a line.
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.
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.