Extends PathItem
The Path item represents a path in an Illustrator document.
Constructors
Creates a Path Item with two anchor points forming a line.
Sample code:
var path = new Path.Line(new Point(20, 20, new Point(100, 100));
- Returns:
- Path — the newly created path
Creates a Path Item with two anchor points forming a line.
Sample code:
var path = new Path.Line(20, 20, 100, 100);
- Returns:
- Path — the newly created path
Creates a rectangular shaped Path Item.
Sample code:
var rectangle = new Rectangle(new Point(100, 100), new Size(100, 100)); var path = new Path.Rectangle(rectangle);
- Returns:
- Path — the newly created path
Creates a rectangular shaped Path Item.
Sample code:
var path = new Path.Rectangle(100, 100, 10, 10);
- Returns:
- Path
Creates a rectangle shaped Path Item.
Sample code:
var path = new Path.Rectangle(new Point(100, 100), new Size(10, 10));
- Returns:
- Path — the newly created path
Creates a rectangle shaped Path Item from the passed points. These do not necessarily need to be the top left and bottom right corners, the constructor figures out how to fit a rectangle between them.
Sample code:
var path = new Path.Rectangle(new Point(100, 100), new Point(200, 300));
- Returns:
- Path — the newly created path
Creates a rectangular Path Item with rounded corners.
Sample code:
var rectangle = new Rectangle(new Point(100, 100), new Size(100, 100)); var path = new Path.RoundRectangle(rectangle, new Size(30, 30));
- Returns:
- Path — the newly created path
Creates a rectangular Path Item with rounded corners.
Sample code:
var path = new Path.RoundRectangle(new Point(100, 100), new Size(100, 100), new Size(30, 30));
- Returns:
- Path — the newly created path
Creates a rectangular Path Item with rounded corners.
Sample code:
var path = new Path.RoundRectangle(50, 50, 100, 100, 30, 30);
- Returns:
- Path — the newly created path
Creates a regular polygon shaped Path Item.
Sample code:
// Create a triangle shaped path var triangle = new Path.RegularPolygon(new Point(100, 100), 3, 50); // Create a decahedron shaped path var decahedron = new Path.RegularPolygon(new Point(200, 100), 10, 50);
- Returns:
- Path — the newly created path
Creates a star shaped Path Item.
The largest of radius1 and radius2 will be the outer radius of the star. The smallest of radius1 and radius2 will be the inner radius.
Sample code:
var center = new Point(100, 100); var points = 6; var innerRadius = 20; var outerRadius = 50; var path = new Path.Star(center, points, innerRadius, outerRadius);
- Returns:
- Path — the newly created path
Creates a spiral shaped Path Item.
Sample code:
var firstArcCenter = new Point(100, 100); var start = new Point(50, 50); var decayPercent = 90; var numQuarterTurns = 25; var path = new Path.Spiral(firstArcCenter, start, decayPercent, numQuarterTurns, true);
- Returns:
- Path — the newly created path
Creates an oval shaped Path Item.
Sample code:
var rectangle = new Rectangle(new Point(100, 100), new Size(150, 100)); var path = new Path.Oval(rectangle);
- Returns:
- Path — the newly created path
Creates an oval shaped Path Item.
Sample code:
var rectangle = new Rectangle(100, 100, 150, 100); var path = new Path.Oval(rectangle);
- Returns:
- Path — the newly created path
Creates a circle shaped Path Item.
Sample code:
var path = new Path.Circle(new Point(100, 100), 50);
- Returns:
- Path — the newly created path
Creates a circle shaped Path Item.
Sample code:
var path = new Path.Circle(100, 100, 50);
- Returns:
- Path — the newly created path
Creates a circular arc shaped Path Item.
Sample code:
var path = new Path.Arc(new Point(0, 0), new Point(100, 100), new Point(200, 150));
- Returns:
- Path — the newly created path
Properties
Read-only.
- Returns:
- Segment
Read-only.
- Returns:
- Segment
Read-only.
- Returns:
- Curve
Specifies whether the path is closed. If it is closed, Illustrator connects the first and last segments.
- Returns:
- Boolean
The area of the path in square points. Self-intersecting paths can contain sub-areas that cancel each other out. Read-only.
- Returns:
- Number
Tablet Data
- Returns:
- Array of Array of Number
- Returns:
- Array of Array of Number
- Returns:
- Array of Array of Number
- Returns:
- Array of Array of Number
- Returns:
- Array of Array of Number
Functions
Inserts a segment at a given index in the list of this path's segments.
- Parameters:
- index: Number — the index at which to insert the segment.
- segment: Segment — the segment or point to be inserted.
- Returns:
- Segment — the added segment. This is not necessarily the same object, e.g. if the segment to be added already belongs to another path.
- Parameters:
- index: Number
- Returns:
- Segment
- Parameters:
- fromIndex: Number
- toIndex: Number
- Returns:
- Array of Segment, read-only
Approximates the path by converting the points in the path to curves. It only uses the segment.point property of each segment and ignores the segment.handleIn and segment.handleOut properties.
- Parameters:
- tolerance: Number — a smaller tolerance gives a more exact fit and more segments, a larger tolerance gives a less exact fit and fewer segments. — optional, default: 2.5
- threshold: Number — optional, default: 1
- cornerRadius: Number — if, at any point in the fitted curve, the radius of an inscribed circle that has the same tangent and curvature is less than the cornerRadius, a corner point is generated there; otherwise the path is smooth at that point. — optional, default: 1
- scale: Number — the scale factor by which the points and other input units (such as the corner radius) are multiplied. — optional, default: 1
Converts the curves in the path to points.
- Parameters:
- maxPointDistance: Number — the maximum distance between the generated points — optional, default: 1000
- flatness: Number — a value which controls the exactness of the algorithm — optional, default: 0.1
Reduces the amount of segments in the path.
- Parameters:
- flatness: Number — a value which controls the exactness of the algorithm — optional, default: 0.1
- Parameters:
- offset: Number
- Returns:
- Path
- Parameters:
- location: CurveLocation
- Returns:
- Path
- Parameters:
- index: Number
- parameter: Number — optional
- Returns:
- Path
- Parameters:
- path: Path
- Returns:
- Boolean
Smooth bezier curves without changing the amount of segments or their points, by only smoothing and adjusting their handle points, for both open ended and closed paths.
- Parameters:
- point: Point
- precision: Number — optional
- Returns:
- CurveLocation
- Parameters:
- offset: Number
- Returns:
- CurveLocation
Returns the tangential vector to the path at the given offset as a vector point.
- Parameters:
- offset: Number
- Returns:
- Point
Returns the normal vector to the path at the given offset as a vector point.
- Parameters:
- offset: Number
- Returns:
- Point
- Returns:
- Boolean
Inheritance
- PathItem
-
- moveTo(point)
- lineTo(point)
- cubicCurveTo(handle1, handle2, to)
- curveTo(through, to[, parameter])
- quadraticCurveTo(handle, to)
- arcTo(point[, clockwise])
- arcTo(through, to)
- lineBy(vector)
- curveBy(throughVector, toVector[, parameter])
- arcBy(vector[, clockwise])
- arcBy(throughVector, toVector)
- intersects(item)
- contains(item)
- contains(point)
- intersect(item)
- unite(item)
- exclude(item)
- getIntersections(path)
- Item
-
- name
- position
- style
- selected
- fullySelected
- locked
- visible
- clipMask
- targeted
- blendMode
- opacity
- isolated
- knockout
- alphaIsShape
- data
- document
- layer
- parent
- children
- firstChild
- lastChild
- nextSibling
- previousSibling
- index
- bounds
- strokeBounds
- controlBounds
- strokeColor
- strokeWidth
- strokeCap
- strokeJoin
- dashOffset
- dashArray
- miterLimit
- strokeOverprint
- fillColor
- fillOverprint
- windingRule
- resolution
- rasterize(items[, type[, resolution, antialiasing[, width, height]]])
- removeChildren()
- copyTo(document)
- copyTo(item)
- getKnockout(inherited)
- reverseChildren()
- hitTest(point[, request[, tolerance]])
- hitTest(point, tolerance)
- expand([flags[, steps]])
- rasterize([type[, resolution[, antialiasing[, width, height]]]])
- hasChildren()
- isEditable()
- isValid()
- appendTop(item)
- appendBottom(item)
- moveAbove(item)
- moveBelow(item)
- isAbove(item)
- isBelow(item)
- isParent(item)
- isChild(item)
- isDescendant(item)
- isAncestor(item)
- isGroupedWith(item)
- scale(sx, sy[, center])
- scale(scale[, center])
- translate(t)
- rotate(angle[, center])
- shear(shx, shy)
- transform(matrix[, flags])