module Box:A Box is a rectangle with some content and a (not necessarily rectangular) frame. Boxes can be placed, aligned and modified.sig
..end
type
t
type
style =
| |
Rect |
| |
Circle |
| |
RoundRect |
| |
Patatoid |
| |
Patatoid2 |
| |
Ellipse |
| |
RoundBox |
| |
Custom of |
type'a
box_creator =?dx:Num.t ->
?dy:Num.t ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t -> ?fill:Color.t -> 'a -> t
dx
(resp. dy
) is the horizontal
(resp. vertical) padding between the box border and its
contents ; name
, if present, is associated with the box and
can be used to retrieve it using get
; stroke
is the color
used to draw the outline of the box ; when equal to None
,
the outline will not be drawn ; pen
is the pen used to draw
the box's outline, if absent Brush.Pen.default
is used ;
fill
, if present, is the color used to fill the box.val empty : ?width:Num.t ->
?height:Num.t ->
?style:style ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t -> ?fill:Color.t -> unit -> t
val empty_from_box : ?style:style ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t -> ?fill:Color.t -> t -> t
val pic : ?style:style -> Picture.t box_creator
pic p
creates a new box containing the picture p
val path : ?style:style -> Path.t box_creator
path p
creates a new box containing the path p
val tex : ?style:style -> string box_creator
tex s
creates a new box containing the LaTeX string s
val box : ?style:style -> t box_creator
box b
creates a new box containing the box b
val circle : t box_creator
circle pic
creates a circle box containing the picture
pic
. Optional padding is given by arguments dx
and dy
;
default is 2bp.val ellipse : t box_creator
ellipse pic
creates a elliptic box containing the picture
pic
. Optional padding is given by arguments dx
and dy
;
default is 2bpval rect : t box_creator
rect pic
creates a rectangular box containing the picture
pic
. Optional padding is given by arguments dx
and dy
;
default is 2bp.val round_rect : t box_creator
round_rect pic
creates a rectangular box containing the picture
pic
, with rounded corners. Optional padding is given by dx
and dy
; default is 2bpval patatoid : t box_creator
patatoid pic
creates an undefined, vaguely rectangular box
containing the picture pic
. It may happen that the content
overlaps with the box.val patatoid2 : t box_creator
patatoid2 pic
creates an undefined, vaguely rectangular box
containing the picture pic
, which is guaranteed to be fully
contained in the patatoid.val round_box : t box_creator
val bpath : t -> Path.t
val ctr : t -> Point.t
val north : t -> Point.t
val south : t -> Point.t
val west : t -> Point.t
val east : t -> Point.t
val north_west : t -> Point.t
val south_west : t -> Point.t
val north_east : t -> Point.t
val south_east : t -> Point.t
typevposition =
[ `Bot
| `Bottom
| `Center
| `Custom of t -> Num.t
| `North
| `South
| `Top ]
typehposition =
[ `Center
| `Custom of t -> Num.t
| `East
| `Left
| `Right
| `West ]
typeposition =
[ `Bot
| `Bottom
| `Bottomleft
| `Bottomright
| `Center
| `Custom of t -> Point.t
| `East
| `Left
| `Lowerleft
| `Lowerright
| `Lowleft
| `Lowright
| `North
| `Northeast
| `Northwest
| `Right
| `South
| `Southeast
| `Southwest
| `Top
| `Topleft
| `Topright
| `Upleft
| `Upperleft
| `Upperright
| `Upright
| `West ]
val corner : position -> t -> Point.t
val opposite_position : position -> position
val height : t -> Num.t
val width : t -> Num.t
val shift : Point.t -> t -> t
shift pt x
shifts the box x
about the point pt
val center : Point.t -> t -> t
center pt x
centers the box x
at the point pt
val draw : ?debug:bool -> t -> Command.t
debug
: if set to to true, the bounding
path and the center of the box are drawn as well, default is falseval group : ?style:style -> t list box_creator
group bl
groups a list of boxes bl
into a single boxval halign : ?pos:vposition ->
Num.t -> t list -> t list
halign ~pos y l
vertically moves the boxes in l
such that
the vertical position given by pos
is equal to y
. The default
value of pos
is `Center, so by default this function moves each
box such that the y coordinate of its center is y
. The
horizontal position of each box is unchanged.val valign : ?pos:hposition ->
Num.t -> t list -> t list
valign
.val hplace : ?padding:Num.t ->
?pos:position ->
?min_width:Num.t ->
?same_width:bool -> t list -> t list
hplace l
places the boxes of l
horizontally, from left to right
following the order of list elements, without changing their vertical
position.min_width
: minimum width of all boxes; default is zerosame_width
: if true
, all boxes are of same width,
and at least of min_width
; default is falseval vplace : ?padding:Num.t ->
?pos:position ->
?min_height:Num.t ->
?same_height:bool -> t list -> t list
hplace
val hbox : ?padding:Num.t ->
?pos:position ->
?style:style ->
?min_width:Num.t ->
?same_width:bool -> t list box_creator
hbox l
actually gives the same result as
group (hplace (halign l))
.padding
: horizontal padding used to separate the boxes;
defaults to 0pos
: used to determine the way boxes are aligned; defaults to
`Center
val hbox_list : ?padding:Num.t ->
?pos:position ->
?min_width:Num.t ->
?same_width:bool -> t list -> t list
hbox
, but does not group the resulting boxes into a
surrounding box; it returns the list of placed boxes instead.
hbox_list l
is equal to hplace (halign l)
.val vbox : ?padding:Num.t ->
?pos:position ->
?style:style ->
?min_height:Num.t ->
?same_height:bool -> t list box_creator
padding
: vertical padding used to separate the boxespos
: used to determine the way boxes are alignedval vbox_list : ?padding:Num.t ->
?pos:position ->
?min_height:Num.t ->
?same_height:bool -> t list -> t list
val tabular : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
?style:style ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t ->
?fill:Color.t -> t array array -> t
hpadding
(resp. vpadding
);
both default to 0.
Alignment within columns and rows is controlled using pos
.
The arrays for rows must have the same lengths; otherwise
Invalid_argument
is raised.val tabularl : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
?style:style ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t ->
?fill:Color.t -> t list list -> t
tabular
, but using lists instead of arraysval tabulari : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
?style:style ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t ->
?fill:Color.t ->
int -> int -> (int -> int -> t) -> t
tabular
, but using a matrix defined with a functionval hblock : ?padding:Num.t ->
?pos:Command.position ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t ->
?min_width:Num.t ->
?same_width:bool -> t list -> t
hblock bl
aligns the boxes of bl
horizontally and surround
them with new rectangular boxes of the same height; all these new
boxes are packed together into the returned box.min_width
: minimum width of all boxes; default is zerosame_width
: if true
, all boxes are of same width,
and at least of min_width
; default is falseval vblock : ?padding:Num.t ->
?pos:Command.position ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t ->
?min_height:Num.t ->
?same_height:bool -> t list -> t
hblock
, with vertical alignment.min_height
: minimum height of all boxes; default is zerosame_height
: if true
, all boxes are of same height, and at
least of min_height
; default is falseval grid : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t -> t array array -> t
hblock
and vblock
: boxes are aligned in a grid where all cells have
the same size. Each one of these cells is a box containing the
original corresponding box.val gridl : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t -> t list list -> t
grid
, but using lists instead of arraysval gridi : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
?stroke:Color.t option ->
?pen:Pen.t ->
?dash:Dash.t ->
int -> int -> (int -> int -> t) -> t
gridi
, but using a matrix defined with a functionval place : position ->
?pos:position ->
?padding:Num.t -> t -> t -> t
place `East a
is a function which places a box at the east
of a
. Thus, place `East a b
returns a copy of b
placed
at the east of a
.
place posa ~pos: posb ~padding a b
returns a new box c
which is
obtained by moving b
to place the posa
point of a
on top of the
posb
point of b
, and then padding the result by padding
in
direction posa
.
Default value of posb
is the opposite direction of posa
wrt. the
center (see Box.opposite_position
).
Default value of padding
is zero.
The padding argument multiplies a unit vector which goes from
the center of a
to the corner of a
indicated by posa
.
This effectively places point posa
of a
at exactly
padding
units of point posb
of b
, in direction posa
.
This also means that for diagonal directions, the actual
direction will change according to the width / height ratio of
a
.
val nth : int -> t -> t
nth i b
returns the i
-th sub-box of b
. The first sub-box
has index 0. Raises Invalid_argument
if there is no such sub-box.val get : string -> t -> t
get n b
returns the sub-box of b
of name n
, if any, and
raises Invalid_argument
otherwise. The behavior is not specified
if b
contains several sub-boxes with name n
.val sub : t -> t -> t
sub b1 b
returns the sub-box of b
which has the same name as b1
,
if any, and raises Invalid_argument
otherwise. The behavior is not
specified if b
contains several sub-boxes with the name of b1
.val elts : t -> t array
elts b
returns the sub-boxes of b
; returns the empty array for
the empty box or a box containing a picture.val setp : string -> Point.t -> t -> t
val getp : string -> t -> Point.t
val getpx : string -> t -> Num.t
val getpy : string -> t -> Num.t
val get_fill : t -> Color.t option
val set_fill : Color.t -> t -> t
val get_stroke : t -> Color.t option
val set_stroke : Color.t -> t -> t
val clear_stroke : t -> t
val get_name : t -> string option
val set_name : string -> t -> t
val get_pen : t -> Pen.t option
val set_pen : Pen.t -> t -> t
val set_height : Command.vposition -> Num.t -> t -> t
val set_width : Command.hposition -> Num.t -> t -> t
val get_dash : t -> Dash.t option
val set_dash : Dash.t -> t -> t
val clear_dash : t -> t
val set_height2 : vposition ->
Num.t ->
vposition -> Num.t -> t -> t
val set_width2 : hposition ->
Num.t ->
hposition -> Num.t -> t -> t
val set_size : Command.position ->
width:Num.t -> height:Num.t -> t -> t
val same_height : ?pos:vposition -> t list -> t list
val same_width : ?pos:hposition -> t list -> t list
val same_size : ?pos:position -> t list -> t list
val set_post_draw : (t -> Command.t) -> t -> t
val clear_post_draw : t -> t
val set_pre_draw : (t -> Command.t) -> t -> t
val clear_pre_draw : t -> t
val shadow : t -> t
val cpath : ?style:Path.joint ->
?outd:Path.direction ->
?ind:Path.direction ->
?sep:Num.t -> t -> t -> Path.t
val cpath_left : ?style:Path.joint ->
?outd:Path.direction ->
?ind:Path.direction -> t -> Point.t -> Path.t
val cpath_right : ?style:Path.joint ->
?outd:Path.direction ->
?ind:Path.direction -> Point.t -> t -> Path.t
val transform : Transform.t -> t -> t
val scale : Num.t -> t -> t
val rotate : float -> t -> t
val shift : Point.t -> t -> t
val yscale : Num.t -> t -> t
val xscale : Num.t -> t -> t
val set_pos : Point.t -> t -> t