The constructor.
PlotBoilerplate
Private
_guiA storage variable for retrieving the GUI instance once it was created.
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
The event catcher might be a different element positioned over the actual canvas.
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
PlotBoilerplate
Private
keyPlotBoilerplate
PlotBoilerplate
Private
renderA discrete timestamp to identify single render cycles. Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines multiple frames might be rendered within each millisecond.
plotboilerplate
PlotBoilerplate
PlotBoilerplate
Static
Readonly
DEFAULT_Static
Readonly
DEFAULT_Static
Readonly
DEFAULT_Static
Readonly
DEFAULT_Static
Private
DraggableA wrapper class for draggable items (mostly vertices).
Static
utilsA set of helper functions.
Installs vertex listeners to the path's vertices so that controlpoints move with their path points when dragged.
Bézier path points with attr.bezierAutoAdjust==true will have their two control points audo-updated if moved, too (keep path connections smooth).
The path to use auto-adjustment for.
A helper function to the the object property boolean value specified by the given key.
The key of the object property (the name).
A default value if the key does not exist.
A helper function to the the object property function-value specified by the given key.
The key of the object property (the name).
A default value if the key does not exist.
Rest
...args: any[]A helper function to the the object property numeric value specified by the given key.
The key of the object property (the name).
A default value if the key does not exist.
A helper function to the the object property value specified by the given key.
The key of the object property (the name).
A default value if the key does not exist.
Merge the elements in the 'extension' object into the 'base' object based on the keys of 'base'.
base extended by the new attributes.
Private
_handleThis is just a tiny helper function to determine the render color of vertices.
Private
_setPrivate
This function sets the canvas resolution to factor 2.0 (or the preferred pixel ratio of your device) for retina displays. Please not that in non-GL mode this might result in very slow rendering as the canvas buffer size may increase.
_setToRetina
PlotBoilerplate
Private
clearPrivate
clearPrivate
Clear the selection.
This function is usually only used internally.
Optional
redraw: booleanIndicates if the redraw function should be triggered.
this
clearSelection
PlotBoilerplate
Creates a control GUI (a dat.gui instance) for this plot boilerplate instance.
Optional
props: DatGuiProps | LilGuiPropscreateGUI
PlotBoilerplate
Private
drawPrivate
Draw the grid with the current config settings.
This function is usually only used internally.
The drawing library to use to draw lines.
drawGrid
PlotBoilerplate
Private
drawPrivate
Draw the origin with the current config settings.
This function is usually only used internally.
The drawing library to use to draw lines.
drawOrigin
PlotBoilerplate
Private
drawPrivate
Draw the select-polygon (if there is one).
This function is usually only used internally.
drawSelectPolygon
PlotBoilerplate
Private
drawPrivate
Draw all vertices that were not yet drawn with the given render time.
This function is usually only used internally.
The current render time. It is used to distinct already draw vertices from non-draw-yet vertices.
drawVertices
PlotBoilerplate
Set the current zoom and draw offset to fit the given bounds.
This method currently restores the aspect zoom ratio.
Private
getGet the available inner space of the given container.
Size minus padding minus border.
Private
getFPropFind the vertex near the given position.
The position is the absolute vertex position, not the x-y-coordinates on the canvas.
A radius around the position to include into the search. Note that the tolerance will be scaled up/down when zoomed.
The vertex near the given position or undefined if none was found there.
Private
handlePrivate
Handle left-click event.
handleClick
Private
installPrivate
locatePrivate
(Helper) Locates the point (index) at the passed position. Using an internal tolerance of 7 pixels.
The result is an object { type : 'bpath', pindex, cindex, pid }
Returns false if no point is near the passed position.
The polygonal selection area.
Optional
tolerance: numberThe tolerance to use identtifying vertices.
Or false if none found.
locatePointNear
Private
mousePrivate
(Helper) The mouse-down handler.
It selects vertices for dragging.
The event to handle
mouseDownHandler.
Private
mousePrivate
The mouse-drag handler.
It moves selected elements around or performs the panning if the ctrl-key if hold down.
The event to handle
mouseDragHandler.
Private
mousePrivate
The mouse-up handler.
It clears the dragging-selection.
The event to handle
mouseUpHandler.
Private
mousePrivate
The mouse-wheel handler.
It performs the zooming.
The event to handle
mouseWheelHandler.
Remove a vertex from the vertex list.
The vertex to remove.
Optional
redraw: booleanremoveVertex
PlotBoilerplate
Revert a transformed mouse position back to canvas coordinates.
This is the inverse function of transformMousePosition
.
The x component of the position to revert.
The y component of the position to revert.
The canvas coordinates for the given position.
revertMousePosition
PlotBoilerplate
Add all vertices inside the polygon to the current selection.
The polygonal selection area.
selectVerticesInPolygon
PlotBoilerplate
Private
setSet the new draw offset.
Note: the function will not trigger any redraws.
The new draw offset to use.
Private
setSet a new zoom value (and re-adjust the draw offset).
Note: the function will not trigger any redraws.
The new horizontal zoom value.
The new vertical zoom value.
The position of mouse/touch interaction.
Transforms the given x-y-(mouse-)point to coordinates respecting the view offset and the zoom settings.
The x position relative to the canvas.
The y position relative to the canvas.
A simple object
{ x : Number, y : Number }with the transformed coordinates.
transformMousePosition
PlotBoilerplate
Private
updateCSSscaleStatic
Private
_savePrivate
This function opens a save-as file dialog and – once an output file is selected – stores the current canvas contents as an SVG image.
It is the default hook for saving files and can be overwritten.
_saveFile
PlotBoilerplate
Classdesc
The main class of the PlotBoilerplate.
Requires
Vertex
Requires
Line
Requires
Vector
Requires
Polygon
Requires
PBImage
Requires
VEllipse
Requires
Circle
Requires
MouseHandler
Requires
KeyHandler
Requires
VertexAttr
Requires
CubicBezierCurve
Requires
BezierPath
Requires
Drawable
Requires
DrawConfig
Requires
IHooks
Requires
PBParams
Requires
Triangle
Requires
drawutils
Requires
drawutilsgl
Requires
SVGSerializable
Requires
XYCoords
Requires
XYDimension