package toffee

Build not yet checked
  1. Overview
  2. Docs
CSS layout engine for OCaml (Flexbox, Grid, Block)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.3.0.tbz
sha256=a92cbbcbe016fb19fb0a749222da0e459a9567aef3f4c7340d9bd6b71c53ed6f
sha512=6a7ab054605538bb31a2b73a1a6d093981a2704c9f0af5852221c05735290d74aca7c7282298c4d0f91e86a800e2ccd94b4918af883cd963449c758eb6b272b3

doc/toffee.geometry/Toffee_geometry/Rect/index.html

Module Toffee_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

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

'a t represents a rectangle with four edges.

The type parameter 'a allows rectangles of different value types:

  • float option t for optional measurements
  • Dimension.t t for CSS dimension values
  • Length_percentage.t t for length or percentage values

Concrete rectangles of floats are Rectf.t, which store their floats flat.

Constants

Sourceval all : 'a -> 'a t

all value creates a rectangle with all edges set to value.

Creation

Sourceval make : left:'a -> right:'a -> top:'a -> bottom:'a -> 'a t

make ~left ~right ~top ~bottom creates a rectangle.

Mapping Functions

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map f rect applies f to each edge of rect.

Sourceval map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

map2 f r1 r2 applies f to corresponding edges of r1 and r2.

Sourceval zip_size : 'b Size.t -> ('a -> 'b -> 'c) -> 'a t -> 'c t

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

Sourceval horizontal_components : 'a t -> 'a Line.t

horizontal_components rect extracts the left and right edges as a line.

Sourceval vertical_components : 'a t -> 'a Line.t

vertical_components rect extracts the top and bottom edges as a line.

Comparison and String Functions

Sourceval compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp a b lexicographically compares a and b using cmp.

Edges are compared in order: left, right, top, bottom.

Sourceval equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal eq a b tests if a and b are equal using eq for each edge.

Sourceval to_string : ('a -> string) -> 'a t -> string

to_string f rect converts rect to a string representation using f for each edge.

Sourceval pp : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit

pp f fmt rect prints rect to fmt using f for each edge.