events:
'natural'
)
:
#_drawCoordinates(x, y)
[PRIVATE] Display xy coordinates on the upper left corner
[PRIVATE] Display xy coordinates on the upper left corner
#_drawGrid
[PRIVATE] Draw the background grid
[PRIVATE] Draw the background grid
#_fillBackground
[PRIVATE] Paint the background with a given color
[PRIVATE] Paint the background with a given color
#_onCanvasMouseDbclick(evt)
EVENT for when we double click on the canvas
EVENT for when we double click on the canvas
#_onCanvasMouseDown(evt)
EVENT for when the mouse is clicked over the canvas
EVENT for when the mouse is clicked over the canvas
#_onCanvasMouseEnter(evt)
EVENT The mouse enters the canvas
EVENT The mouse enters the canvas
#_onCanvasMouseLeave(evt)
EVENT for when the mouse is leaving the canvas
EVENT for when the mouse is leaving the canvas
#_onCanvasMouseMove(evt)
EVENT for when the mouse is moving over the canvas
EVENT for when the mouse is moving over the canvas
#_onCanvasMouseUp(evt)
EVENT for when the mouse is released over the canvas
EVENT for when the mouse is released over the canvas
#_onKeyUp(evt)
EVENT A keyboard key is released
EVENT A keyboard key is released
#_updateMousePosition(evt)
[PRIVATE] Refresh the position of the pointer we store internally (relative to the canvas)
[PRIVATE] Refresh the position of the pointer we store internally (relative to the canvas)
#add(pt, draw)
Add a point to the collection
Add a point to the collection
Object
pt
:
of type {x: Number, y: Number} and optionnally the boolean properties "xLocked" and "yLocked". x and y must be in [0, 1]
true
)
:
#constructor(parentContainer, width, height, splineType)
Object
parentContainer
:
can be a String: the ID of the parent DIV, or can be directly the DOM element that will host the CanvasSpliner
Number
width
:
width of the canvas where CanvasSpliner draws
Number
height
:
height of the canvas where CanvasSpliner draws
String
splineType
:
"natural" or "monotonic"
#draw
Draw the whole canvas
Draw the whole canvas
#getXSeriesInterpolated
Get an array of all the x coordinates that CanvasSpliner computed an interpolation of. See getYSeriesInterpolated to get the corresponding interpolated values.
Get an array of all the x coordinates that CanvasSpliner computed an interpolation of. See getYSeriesInterpolated to get the corresponding interpolated values.
Array
:
of x values with regular interval in [0, 1]
#getYSeriesInterpolated
Get all the interpolated values for each x given by getXSeriesInterpolated.
Get all the interpolated values for each x given by getXSeriesInterpolated.
Array
:
of interpolated y
#on(eventName, callback)
Define an event
Define an event
String
eventName
:
name of the event. "movePoint", "releasePoint", "pointAdded" or "pointRemoved". They are both called with this in argument
#remove(index)
Remove a point using its index
Remove a point using its index
Number
index
:
index of the point to remove (from left to right, starting at 0)
#setBackgroundColor(color)
Define the canvas background color
Define the canvas background color
String
color
:
must be css style best is of form "rgba(244, 66, 167, 0.5)" Can allso be null/0/false to leave a blank background
#setControlPointRadius(r)
Change the radius of the control points
Change the radius of the control points
Number
r
:
the radius in pixel
#setCurveThickness(t)
Define the thickness of the curve
Define the thickness of the curve
Number
t
:
thickness in pixel
#setGridColor(color)
Set the color of the grid
Set the color of the grid
String
color
:
must be css style best is of form "rgba(244, 66, 167, 0.5)"
#setGridStep(Number, gs)
Define the grid step in unit coodinate. Default: 0.33
Define the grid step in unit coodinate. Default: 0.33
#setSplineType(splineType)
String
splineType
:
"natural" or "monotonic"
#setTextColor(color)
Set the color of the text
Set the color of the text
String
color
:
must be css style best is of form "rgba(244, 66, 167, 0.5)"
#add(p)
#getClosestFrom(p)
Get the index within the collection of the point that is the closest from the one given in argument. Returns also the euclidiant distance to this point.
Get the index within the collection of the point that is the closest from the one given in argument. Returns also the euclidiant distance to this point.
Object
:
like {index: Number, distance: Number}, or null if there is no point in this collection.
#getNumberOfPoints
Get the number of points in the collection
Get the number of points in the collection
Number
:
the number of points
#getXseries
Get all "x" coordinates of the collection as an array of Number
Get all "x" coordinates of the collection as an array of Number
Array
:
of Number
#getYseries
Get all "y" coordinates of the collection as an array of Number
Get all "y" coordinates of the collection as an array of Number
Array
:
of Number
#updatePoint(index, p)
Update the posiiton of an existing point
Update the posiiton of an existing point
Number
index
:
index of the existing point to update
Object
p
:
point that has coord we want to use as new coord. x and y values will be copied, no pointer association
Number
:
new index, the changed point may have changed its index among the x-ordered list