The SDL2 backend of System.Plot: it draws the same PlotScene the SVG writer does, to a window you can zoom, pan and hover, or to a PNG file. Compile with -lib plot_sdl,plot,sdl2,gen_collect. Saving a PNG needs no window and no display; a window needs one. Not available in the web playground. Design: docs/PLOT_DESIGN.md.
SdlCanvas
Draws a PlotScene with an SDL2 Renderer: lines (anti-aliased, or thick, or dashed), polylines, polygons, rectangles with opacity, circles, and text. Text uses SDL_ttf when a font file is found (the shipped lib/sdl/fonts/lato.ttf, or the one given to SetFont) and falls back to SDL2_gfx's built-in 8x8 bitmap font, which cannot rotate or bold.
Operations
Draw #
Clears the target to white and draws a scene on it. Call Present (or save) afterwards.
method : public : Draw(scene:PlotScene) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| scene | PlotScene | what to draw |
GetFont #
The font file text will use.
method : public : GetFont() ~ StringReturn
| Type | Description |
|---|---|
| String | the path, or an empty string for the bitmap fallback |
New # constructor
Constructor
New(renderer:Renderer, width:Int, height:Int)Parameters
| Name | Type | Description |
|---|---|---|
| renderer | Renderer | the renderer to draw on |
| width | Int | width of the render target in pixels |
| height | Int | height of the render target in pixels |
Overlay #
Draws a scene over what is already there, without clearing, for readouts and labels.
method : public : Overlay(scene:PlotScene) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| scene | PlotScene | what to draw |
Release #
Frees the cached fonts. Call it when finished drawing, before Font->Quit.
method : public : Release() ~ Nil