package toffee
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
CSS layout engine for OCaml (Flexbox, Grid, Block)
Install
dune-project
Dependency
Authors
Maintainers
Sources
mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/src/toffee.geometry/rect.ml.html
Source file rect.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90type 'a t = { left : 'a; right : 'a; top : 'a; bottom : 'a } (* Constants *) let zero = { left = 0.0; right = 0.0; top = 0.0; bottom = 0.0 } let all value = { left = value; right = value; top = value; bottom = value } (* Creation *) let make ~left ~right ~top ~bottom = { left; right; top; bottom } (* Mapping functions *) let map f rect = { left = f rect.left; right = f rect.right; top = f rect.top; bottom = f rect.bottom; } let map2 f r1 r2 = { left = f r1.left r2.left; right = f r1.right r2.right; top = f r1.top r2.top; bottom = f r1.bottom r2.bottom; } let zip_size size f rect = { left = f rect.left size.Size.width; right = f rect.right size.Size.width; top = f rect.top size.height; bottom = f rect.bottom size.height; } (* Component extraction *) let horizontal_components rect = Line.{ start = rect.left; end_ = rect.right } let vertical_components rect = Line.{ start = rect.top; end_ = rect.bottom } (* Arithmetic operations *) let add a b = { left = a.left +. b.left; right = a.right +. b.right; top = a.top +. b.top; bottom = a.bottom +. b.bottom; } let ( + ) = add (* Axis sums *) let horizontal_axis_sum rect = rect.left +. rect.right let vertical_axis_sum rect = rect.top +. rect.bottom let sum_axes rect = { Size.width = horizontal_axis_sum rect; height = vertical_axis_sum rect } let grid_axis_sum axis rect = match axis with | Absolute_axis.Horizontal -> rect.left +. rect.right | Absolute_axis.Vertical -> rect.top +. rect.bottom (* Comparison and string functions *) let compare cmp a b = let cmp_left = cmp a.left b.left in if cmp_left <> 0 then cmp_left else let cmp_right = cmp a.right b.right in if cmp_right <> 0 then cmp_right else let cmp_top = cmp a.top b.top in if cmp_top <> 0 then cmp_top else cmp a.bottom b.bottom let equal eq a b = eq a.left b.left && eq a.right b.right && eq a.top b.top && eq a.bottom b.bottom let to_string f rect = Printf.sprintf "{ left: %s; right: %s; top: %s; bottom: %s }" (f rect.left) (f rect.right) (f rect.top) (f rect.bottom) let pp f fmt rect = Format.fprintf fmt "{ left: %a; right: %a; top: %a; bottom: %a }" f rect.left f rect.right f rect.top f rect.bottom
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>