package grenier
A collection of various algorithms in OCaml.
Install
Dune Dependency
Authors
Maintainers
Sources
grenier-0.7.tbz
sha256=c2ab40ae80bce5e48f940925dc594f0886c1e54281ed32f28902bea3a3fe5de9
md5=fea64f9534b5a99df7d53665692af0be
doc/grenier.binpacking/Maxrects/index.html
Module Maxrects
val empty : 'bin t
make ~width ~height
return a packer ready to place stuff in a width * height
area
type 'tag box = {
tag : 'tag;
width : int;
height : int;
allow_rotation : bool;
(*can the box be rotated to optimize packing
*)
}
Input to packing is a box
val box : ?allow_rotation:bool -> 'tag -> int -> int -> 'tag box
type ('bin, 'tag) rect = {
x : int;
y : int;
w : int;
h : int;
rotated : bool;
(*True iff the input box was rotated. If true, w = box.height && h = box.width Otherwise, w = box.width && h = box.height
*)bin : 'bin;
box : 'tag box;
}
Output of packing is an optional rectangle
Online insertion of one item. Efficient but the packing is not very good.
Worst-case: O(n^3) (n is total number of items inserted).
val insert_batch :
'bin t ->
?heuristic:heuristic ->
'tag box list ->
'bin t * ('bin, 'tag) rect option list
Online insertion of a batch of items. Runtime is roughly the cost of inserting each item independently, but order of insertion is chosen to give a better packing.
Worst-case: O(n^4) (n is total number of items inserted).
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>