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.
Path.addArc(var area, var fromRadians, var toRadians)
addArrow
Adds an arrow to the path from start [x, y] and end [x, y].
Path.addArrow(var start, var end, var thickness, var headWidth, var headLength)
addEllipse
Adds an ellipse to the path.
Path.addEllipse(var area)
addPolygon
Adds a polygon to the path from the center [x, y].
Path.addPolygon(var center, var numSides, var radius, var angle)
addQuadrilateral
Adds a addQuadrilateral to the path.
Path.addQuadrilateral(var xy1, var xy2, var xy3, var xy4)
addRectangle
Adds a rectangle to the path.
Path.addRectangle(var area)
addRoundedRectangle
Adds a rounded rectangle to the path.
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]
Path.addRoundedRectangleCustomisable(var area, var cornerSizeXY, var boolCurves)
addStar
Adds a star to the path from the center [x, y].
Path.addStar(var center, var numPoints, var innerRadius, var outerRadius, var angle)
addTriangle
Adds a triangle to the path.
Path.addTriangle(var xy1, var xy2, var xy3)
clear
Clears the Path.
Path.clear()
closeSubPath
Closes the Path.
Path.closeSubPath()
contains
Checks whether a point lies within the path. This is only relevant for closed paths.
Path.contains(var point)
createStrokedPath
Creates a fillable path using the provided strokeData (with optional dot.
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].
Path.cubicTo(var cxy1, var cxy2, var x, var y)
fromString
Restores a path that has been converted into a string.
Path.fromString(String stringPath)
getBounds
Returns the area ([x, y, width, height]) that the path is occupying with the scale factor applied.
Path.getBounds(var scaleFactor)
getIntersection
Returns the point where a line ([x1, y1], [x2, y2]) intersects the path when appropriate. Returns false otherwise.
Path.getIntersection(var start, var end, bool keepSectionOutsidePath)
getLength
Returns the length of the path.
Path.getLength()
getPointOnPath
Returns the point at a certain distance along the path.
Path.getPointOnPath(var distanceFromStart)
lineTo
Adds a line to [x,y].
Path.lineTo(var x, var y)
loadFromData
Loads a path from a data array.
Path.loadFromData(var data)
quadraticTo
Adds a quadratic bezier curve with the control point [cx,cy] and the end point [x,y].
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.
Path.roundCorners(var radius)
scaleToFit
Rescales the path to make it fit neatly into a given space. preserveProportions keeps the w/h ratio.
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.
Path.startNewSubPath(var x, var y)
toBase64
Creates a base64 encoded representation of the path.
Path.toBase64()
toString
Creates a string representation of this path.
Path.toString()