package vg
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=ccd0d0f61cdbdb3420b5f4d747fe6e6b95e487738f70163a6e26396b1eeb9a42118306bc9c2c9afc9256171d57f81fbdf08ec558625eb5d723230aa0e9564fb6
doc/vg/Vg/I/index.html
Module Vg.ISource
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
void is const Gg.Color.void, an invisible black image. void is an identity element for blend.
Primitive images
axial stops pt pt' is an image with an axial color gradient varying between pt and pt' according to color stops stops.
- [
axial stops pt pt']q=[stops]tifqis on the line perpendicular to the lineptandpt'at the pointpt + t * (pt' - pt).
radial stops ~f c r is an image with a color gradient varying according to color stops stops on circles whose center are on the segment from f to c and radius vary, respectively, from 0 to r. The focus f defaults to c, it must be inside the circle (c, r).
- [
radial stops ~f c r]p=[stops]tiftis the smallest value such thatpis on the circle defined by radiust * rand centerf + t * (c - f).
Cutting images
cut area p i is i with the area outside [a, p] cut out, i.e. mapped to Gg.Color.void. area defaults to `Anz.
- [
cut area p i]pt=[i]ptif [a,p]pt - [
cut area p i]pt=Gg.Color.voidotherwise.
Warning. For outline cuts most renderers support only cutting into const axial and radial 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 ->
imageWARNING. 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 cut except the path cut is the union of all the paths of the glyphs glyphs of the font font.
The origin of the first glyph is set to P2.o, the origin of each subsequent glyph in glyphs is offset by the advance vector of the previous glyph as provided by font. Advance vectors for each glyph can be overriden by providing their value in advances, if the length of advances is smaller than glyphs 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 between glyphs and the characters of text. 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 is true the glyph sequence is reversed for peforming the map. If blocks 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
blend src dst is src blended over dst using source over destination alpha blending.
- [
blend src dst]p=Color.blend[src]p[dst]p
Transforming images
move v i is i translated by v.
- [
move v i]pt=[i]pt-vfor anypt
rot a i is i rotated by a.
- [
rot a i]pt=[i]m⋅ptfor anyptand withm = M2.rot -a.
scale s i is i scaled by s.
- [
scale s i](x,y)=[i](x/sx,y/sy)for any(x,y)
tr m i is the affine transform in homogenous 2D space of each point of i by m (see Gg.P2.tr).
- [
tr m i]pt=[i]m-1⋅ptfor anypt
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.
equal eq i i' is like equal but uses eq to test floating point values.
Note. Raster images are tested with Gg.Raster.equal.
compare_f cmp i i' is like compare but uses cmp to compare floating point values.
Note. Raster images are tested with Gg.Raster.compare.
Formatters
pp ppf i prints a textual representation of i on ppf.
pp_f pp_float ppf i prints i like pp but uses pp_float to print floating point values.