Module Vg.I
Images.
Consult their semantics.
The |>
operator is used to compose images. For this reason image combinators always take the image to use as the last argument.
Images
type t
= image
The type for images.
val void : image
void
isconst
Gg
.Color.void, an invisible black image.void
is an identity element for Blending images.
Primitive images
val const : Gg.color -> image
const c
is an image of colorc
.- [
const c
]pt
= c
for anypt
.
- [
val axial : Gg.Color.stops -> Gg.p2 -> Gg.p2 -> image
axial stops pt pt'
is an image with an axial color gradient varying betweenpt
andpt'
according to color stopsstops
.- [
axial stops pt pt'
]q
=
[stops
]t
ifq
is on the line perpendicular to the linept
andpt'
at the pointpt + t * (pt' - pt)
.
- [
val radial : Gg.Color.stops -> ?f:Gg.p2 -> Gg.p2 -> float -> image
radial stops ~f c r
is an image with a color gradient varying according to color stopsstops
on circles whose center are on the segment fromf
toc
and radius vary, respectively, from0
tor
. The focusf
defaults toc
, it must be inside the circle(c, r)
.- [
radial stops ~f c r
]p
=
[stops
]t
ift
is the smallest value such thatp
is on the circle defined by radiust * r
and centerf + t * (c - f)
.
- [
Cutting images
val cut : ?area:P.area -> path -> image -> image
cut area p i
isi
with the area outside [a
,p
] cut out, i.e. mapped toGg
.Color.void.area
defaults to`Anz
.- [
cut area p i
]pt
=
[i
]pt
if [a
,p
]pt
- [
cut area p i
]pt
=
Gg
.Color.void otherwise.
Warning. For outline cuts most renderers support only cutting into
const
axial
andradial
images. Consult the individual renderer documentation.- [
val cut_glyphs : ?area:[ `O of P.outline ] -> ?text:string -> ?blocks:(bool * (int * int) list) -> ?advances:Gg.v2 list -> font -> glyph list -> image -> image
WARNING. The interface and specifics of glyph rendering are still subject to change in the future.
cut_glyphs area text blocks advances font glyphs i
is like Cutting images except the path cut is the union of all the paths of the glyphsglyphs
of the fontfont
.The origin of the first glyph is set to
P2.o
, the origin of each subsequent glyph inglyphs
is offset by the advance vector of the previous glyph as provided byfont
. Advance vectors for each glyph can be overriden by providing their value inadvances
, if the length ofadvances
is smaller thanglyphs
the rendering results are undefined.If provided the
text
parameter indicates the UTF-8 text corresponding to the sequence of glyphs. This may be used by certain renderer to allow text search in the result or to draw the text if it lacks control over glyph rendering (in which case an empty list of glyphs may be passed).If provided
blocks
is used to specify a sequential map betweenglyphs
and the characters oftext
. The number of elements in the list defines the number of blocks. Starting at the head of each sequence, each block(char_adv, glyph_adv)
indicates the number of characters and glyphs that make the next block (one or the other may be 0). If the boolean istrue
the glyph sequence is reversed for peforming the map. Ifblocks
is unspecified a one to one map between glyphs and characters is assumed with undefined results if the number of glyphs and characters differ.If
area
is provided, the outline area of the glyphs are cut as specified, otherwise the area of the glyphs is determined as mandated by the font. Warning. Backend support is poor this may be removed in the future.
Blending images
Transforming images
val rot : float -> image -> image
rot a i
isi
rotated bya
.- [
rot a i
]pt
=
[i
]m⋅pt
for anypt
and withm = M2.rot -a
.
- [
Predicates and comparisons
Note. These predicates consider the structure of image values not their denotational interpretation; a single denotational interpretation can have many structural representations.
val is_void : image -> bool
is_void i
isi == void
.
Printers
val to_string : image -> string
to_string i
is a textual representation ofi
.
val pp : Stdlib.Format.formatter -> image -> unit
pp ppf i
prints a textual representation ofi
onppf
.