Path
The Path
object with which you can define a path that can be drawn to a Panel
. You can create a new path object with Content.createPath()
and draw it with Graphics.drawPath()
.
const var p = Content.createPath();
p.startNewSubPath(0.0, 0.0);
p.lineTo(0.2, 1.0);
p.lineTo(1.0, 0.2);
p.lineTo(0.7, 1.0);
const var Panel1 = Content.getComponent("Panel1");
Panel1.setPaintRoutine(function(g)
{
g.setColour(Colours.white);
var path_data = {}; // pathStrokeStyle object
path_data.Thickness = 3.0;
g.drawPath(p, this.getLocalBounds(10), path_data);
});
Class methods
addArc
Adds an arc to the path. Edit on GitHub
Path.addArc(var area, var fromRadians, var toRadians)
addArrow
Adds an arrow to the path from start [x, y] and end [x, y]. Edit on GitHub
Path.addArrow(var start, var end, var thickness, var headWidth, var headLength)
addEllipse
Adds an ellipse to the path. Edit on GitHub
Path.addEllipse(var area)
addPolygon
Adds a polygon to the path from the center [x, y]. Edit on GitHub
Path.addPolygon(var center, var numSides, var radius, var angle)
addQuadrilateral
Adds a addQuadrilateral to the path. Edit on GitHub
Path.addQuadrilateral(var xy1, var xy2, var xy3, var xy4)
addRectangle
Adds a rectangle to the path. Edit on GitHub
Path.addRectangle(var area)
addRoundedRectangle
Adds a rounded rectangle to the path. Edit on GitHub
Path.addRoundedRectangle(var area, var cornerSize)
addRoundedRectangleCustomisable
Adds a fully customisable rounded rectangle to the path. area[x,y,w,h], cornerSizeXY[x,y], boolCurves[bool,bool,bool,bool] Edit on GitHub
Path.addRoundedRectangleCustomisable(var area, var cornerSizeXY, var boolCurves)
addStar
Adds a star to the path from the center [x, y]. Edit on GitHub
Path.addStar(var center, var numPoints, var innerRadius, var outerRadius, var angle)
addTriangle
Adds a triangle to the path. Edit on GitHub
Path.addTriangle(var xy1, var xy2, var xy3)
clear
Clears the Path. Edit on GitHub
Path.clear()
closeSubPath
Closes the Path. Edit on GitHub
Path.closeSubPath()
contains
Checks whether a point lies within the path. This is only relevant for closed paths. Edit on GitHub
Path.contains(var point)
createStrokedPath
Creates a fillable path using the provided strokeData (with optional dot. Edit on GitHub
Path.createStrokedPath(var strokeData, var dotData)
cubicTo
Adds a cubic bezier curve with two sets of control point arrays [cx1,cy1] and [cx2,cy2], and the end point [x,y]. Edit on GitHub
Path.cubicTo(var cxy1, var cxy2, var x, var y)
fromString
Restores a path that has been converted into a string. Edit on GitHub
Path.fromString(String stringPath)
getBounds
Returns the area ([x, y, width, height]) that the path is occupying with the scale factor applied. Edit on GitHub
Path.getBounds(var scaleFactor)
getIntersection
Returns the point where a line ([x1, y1], [x2, y2]) intersects the path when appropriate. Returns false otherwise. Edit on GitHub
Path.getIntersection(var start, var end, bool keepSectionOutsidePath)
getLength
Returns the length of the path. Edit on GitHub
Path.getLength()
getPointOnPath
Returns the point at a certain distance along the path. Edit on GitHub
Path.getPointOnPath(var distanceFromStart)
lineTo
Adds a line to [x,y]. Edit on GitHub
Path.lineTo(var x, var y)
loadFromData
Loads a path from a data array. Edit on GitHub
Path.loadFromData(var data)
quadraticTo
Adds a quadratic bezier curve with the control point [cx,cy] and the end point [x,y]. Edit on GitHub
Path.quadraticTo(var cx, var cy, var x, var y)
roundCorners
Creates a version of this path where all sharp corners have been replaced by curves. Edit on GitHub
Path.roundCorners(var radius)
scaleToFit
Rescales the path to make it fit neatly into a given space. preserveProportions keeps the w/h ratio. Edit on GitHub
Path.scaleToFit(var x, var y, var width, var height, bool preserveProportions)
startNewSubPath
Starts a new Path. It does not clear the path, so use 'clear()' if you want to start all over again. Edit on GitHub
Path.startNewSubPath(var x, var y)
toBase64
Creates a base64 encoded representation of the path. Edit on GitHub
Path.toBase64()
toString
Creates a string representation of this path. Edit on GitHub
Path.toString()