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/point.ml.html
Source file point.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 60type 'a t = { x : 'a; y : 'a } (* Constants *) let zero = { x = 0.0; y = 0.0 } let none = { x = None; y = None } (* Creation *) let make x y = { x; y } (* Arithmetic operations *) let add a b = { x = a.x +. b.x; y = a.y +. b.y } let sub a b = { x = a.x -. b.x; y = a.y -. b.y } let ( + ) = add let ( - ) = sub let mul_scalar point scalar = { x = point.x *. scalar; y = point.y *. scalar } let div_scalar point scalar = { x = point.x /. scalar; y = point.y /. scalar } let ( * ) = mul_scalar let ( / ) = div_scalar (* Mapping *) let map f point = { x = f point.x; y = f point.y } let map2 f p1 p2 = { x = f p1.x p2.x; y = f p1.y p2.y } (* Axis accessors *) let get axis point = match axis with | Abstract_axis.Inline -> point.x | Abstract_axis.Block -> point.y let set axis value point = match axis with | Abstract_axis.Inline -> { point with x = value } | Abstract_axis.Block -> { point with y = value } (* Transformations *) let transpose point = { x = point.y; y = point.x } (* Conversions *) let to_size point = { Size.width = point.x; height = point.y } let of_size size = { x = size.Size.width; y = size.Size.height } (* Comparison and string functions *) let compare cmp a b = let cmp_x = cmp a.x b.x in if cmp_x <> 0 then cmp_x else cmp a.y b.y let equal eq a b = eq a.x b.x && eq a.y b.y let to_string f point = Printf.sprintf "{ x: %s; y: %s }" (f point.x) (f point.y) let pp f fmt point = Format.fprintf fmt "{ x: %a; y: %a }" f point.x f point.y
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>