val screen_resolution : Gg.v2
screen_resolution is the screen resolution in pixels per meters.
val target : ?resize:bool -> ?resolution:Gg.v2 -> Js_of_ocaml.Dom_html.canvasElement Js_of_ocaml.Js.t -> [ `Other ] Vg.Vgr.target
target resize resolution c is a render target for rendering to the canvas element
true(default) sets the canvas CSS size to the physical size of renderables. If
falsethe physical size of renderables is ignored and the view rectangle is simply mapped on the canvas CSS size at the given resolution but WARNING for this to work do not use any CSS
borderon the canvas element (
outlinecan be used though) as it interacts badly with the underlying canvas size computation made by
Vgr_htmlc(a typical symptom will be a vertically growing canvas on redraws, this seems to happen regardless of
resolution, specifies the rendering resolution in samples per meters. If unspecified the
screen_resolutionis used in both dimensions.
Multiple images. Multiple images render on the target is supported. Each new render clears the HTML canvas.
Text rendering uses the HTML canvas CSS font selection mechanism. As there is no control over glyph rendering in the HTML canvas, the glyph API is unsupported.
Given a glyph cut:
~text ~blocks ~advances font glyphs
glyphs parameters are ignored.
text must be provided and is used to define the text to render.
font is used to select the font in the CSS stylesheet. Make sure that the fonts you use are embedded and loaded in your DOM via
At the moment the renderer also needs to work around a particular browser bug which means that glyph cuts are currently limited to non-outline area cuts in
The following render warnings are reported.
`Unsupported_cut ((`O o), i), outline area cuts can be performed only on (possibly transformed)
I.radial primitive images.
`Unsupported_glyph_cut (a, i), glyph cuts can be performed only on bare
I.const primitive images and outline area glyph cuts are currently unsupported.
`Textless_glyph_cut iif no
textargument is specified in a glyph cut.
`Other _if dashes are rendered but unsupported by the browser.
The following limitations should be taken into account.
- The even-odd area rule is supported according to the latest whatwg spec. This may not work in all browsers.
- In the HTML canvas gradient color interpolation is performed in (non-linear) sRGB space. This doesn't respect Vg's semantics.