module Shape:sig..end
Shape contains the Shape.t type and utilities for creating and
manipulating shapes. A Shape.t is a vector representation of a
drawing command and serves as the basis for all drawing operations
in p5ml.
type tag = ..
tag is an extensible variant for attaching arbitrary metadata to
shapes.
type tag +=
| |
TName of |
type vertex = private
| |
MoveTo of |
(* |
| *) |
| |
LineTo of |
(* |
| *) |
| |
BezierTo of |
(* |
| *) |
| |
Arc of |
(* |
| *) |
| |
ClosePath |
(* |
| *) |
The type of a vertex, a single piece of vector information that forms a shape.
type t = private
| |
Shape of |
(* |
| *) |
| |
Group of |
(* |
| *) |
| |
Paint of |
(* |
| *) |
| |
Tag of |
(* |
| *) |
| |
Background of |
(* |
| *) |
| |
Empty |
(* |
| *) |
The type of a shape, a component that can be displayed.
The Shape constructor contains vertices.
val poly : ?close:[ `Close | `Open ] -> Math.vector list -> tpoly vertices is the shape representing the polygon with vertices.
val point : Math.vector -> tpoint vertex is the shape representing the point at position vertex.
val line : Math.vector -> Math.vector -> tline v1 v2 is the shape representing the line between v1 and v2.
val rect : Math.vector -> ?align:[ `Center | `Corner ] -> Math.vector -> trect point size is the shape representing the rectangle with corner at
point and dimensions size.
val quad : Math.vector -> Math.vector -> Math.vector -> Math.vector -> tquad v1 v2 v3 v3 is polygon [v1; v2; v3; v4].
val triangle : Math.vector -> Math.vector -> Math.vector -> ttriangle v1 v2 v3 is polygon [v1; v2; v3].
val ellipse : Math.vector -> ?align:[ `Center | `Corner ] -> Math.vector -> tellipse point size is the shape representing the ellipse centered at
point and inscribed in rect point ~align:`Center size.
val circle : Math.vector -> ?align:[ `Center | `Corner ] -> float -> tcircle point radius is ellipse point (radius, radius).
val arc : Math.vector ->
?align:[ `Center | `Corner ] ->
Math.vector ->
?stroke_mode:[ `Closed | `Open ] ->
?fill_mode:[ `Chord | `Pie ] -> ?phi:float -> float -> float -> tarc point size theta1 theta2 is the shape representing the arc (portion
of a full ellipse) centered at point and inscribed in
rect point ~align:`Center size from angle theta1 to theta2.
val bezier : Bezier.t -> tbezier bez is the shape representing the Bezier curve bez.
val group : t list -> tgroup shapes is the shape that draws shapes in order.
val shape : t -> Math.vector -> tshape sh tr is the shape sh translated by tr.
val background : Color.color -> tbackground color is the shape that sets the background to color.
val empty : tempty is the shape that draws nothing.
val fill : Color.color -> t -> tfill color shape is shape with fill color, used to draw the inside
of shapes.
val no_fill : t -> tno_fill shape is shape with fill cleared.
val stroke : Color.color -> t -> tstroke color shape is shape with stroke color, used to draw the
outline of shapes.
val no_stroke : t -> tno_stroke shape is shape with stroke cleared.
val stroke_weight : float -> t -> tstroke_weight w shape is shape with stroke weight w, the width of
the stroke lines.
val stroke_cap : [ `Project | `Round | `Square ] -> t -> tstroke_cap c shape is shape with stroke cap c, the way that the ends
of lines are drawn.
val stroke_join : [ `Bevel | `Miter | `Round ] -> t -> tstroke_join j shape is shape with stroke join j, the way that vertices
between two lines are drawn.
val bleach : t -> tbleach shape is shape with all color (fill or stroke) information
removed.
val name : string -> t -> tname n shape is shape tagged with name n, which can be looked up
with find_name.
val find_name : string -> t -> t optionfind_name name shape is Some found where found is the first shape
tagged with name in shape, or None if shape contains no shapes
tagged name.
val find_names : string -> t -> t listfind_names name shape is the list of all shapes in shape that are
tagged with name.
val tag : tag -> t -> ttag tg shape is shape tagged with tag tg, which can be looked up with
find_tag. Tags are a more general form of names.
val find_tag : ?eq:(tag -> tag -> bool) ->
tag -> t -> t optionfind_tag tag shape is Some found where found is the first shape tagged
with tag in shape, or None if shape contains no shapes tagged
tag.
: ?eq:(tag -> tag -> bool) -> tag -> t -> t listfind_tags tag shape is the list of all shapes in shape that are tagged
with tag.
val translate : Math.vector -> t -> ttranslate tr shape is shape translated by offset tr.
val scale : Math.vector -> t -> tscale (scale_x, scale_y) shape is shape scaled by factors of scale_x
and scale_y in the x and y directions, respectively, about the origin.
To achieve scaling about a different center, first use translate.
val rotate : float -> t -> trotate angle shape is shape rotated angle radians about the origin.
To achieve rotation about a different center, first use translate.