The Item type allows you to access and modify the artwork items in Illustrator documents. Its functionality is inherited by different document item types such as Path, CompoundPath, Group, Layer and Raster. They each add a layer of functionality that is unique to their type, but share the underlying properties and functions that they inherit from Item.
The name of the item as it appears in the layers palette.
Sample code:
var layer = new Layer(); // a layer is an item print(layer.name); // null layer.name = 'A nice name'; print(layer.name); // 'A nice name'
The item's position within the art board. This is the rectangle.center of the bounds rectangle.
Sample code:
// Create a circle at position { x: 10, y: 10 } var circle = new Path.Circle(new Point(10, 10), 10); // Move the circle to { x: 20, y: 20 } circle.position = new Point(20, 20); // Move the circle 10 points to the right circle.position += new Point(10, 0); print(circle.position); // { x: 30, y: 20 }
Specifies whether an item is selected.
Sample code:
print(document.selectedItems.length); // 0 var path = new Path.Circle(new Size(50, 50), 25); path.selected = true; // Select the path print(document.selectedItems.length) // 1
Specifies whether the item is fully selected. For paths this means that all segments are selected, for container items (groups/layers) all children are selected.
Specifies whether the item is locked.
Sample code:
var path = new Path(); print(path.locked) // false path.locked = true; // Locks the path
Specifies whether the item is visible.
Sample code:
var path = new Path(); print(path.visible) // true path.visible = false; // Hides the path
Specifies whether the item defines a clip mask. This can only be set on paths, compound paths, and text frame objects, and only if the item is already contained within a clipping group.
Sample code:
var group = new Group(); group.appendChild(path); group.clipped = true; path.clipMask = true;
Specifies whether the item is targeted.
Sample code:
var path = new Path(); print(path.targeted) // false path.targeted = true; // Marks the the path as targeted
The blend mode of the item.
Sample code:
var circle = new Path.Circle(new Point(50, 50), 10); print(circle.blendMode); // normal // Change the blend mode of the path item: circle.blendMode = 'multiply';
The opacity of the item.
Sample code:
// Create a circle at position { x: 10, y: 10 } var circle = new Path.Circle(new Point(10, 10), 10); // Change the opacity of the circle to 50%: circle.opacity = 0.5;
An object contained within the item which can be used to store data.
The values in this object can be accessed even after the file has been closed and opened again. Since these values are stored in a native structure, only a limited amount of value types are supported: Number, String, Boolean, Item, Point, Matrix.
Sample code:
var path = new Path.Circle(new Point(50, 50), 50); path.data.point = new Point(50, 50); print(path.data.point); // {x: 50, y: 50}
The children items contained within this item.
Sample code:
var group = new Group(); // the group doesn't have any children yet print(group.children.length); // 0 var path = new Path(); path.name = 'pathName'; // append the path in the group group.appendTop(path); print(group.children.length); // 1 // access children by index: print(group.children[0]); // Path (pathName) // access children by name: print(group.children['pathName']); // Path (pathName)
The index of this item within the list of it's parent's children.
Read-only.
The bounding rectangle of the item including stroke width and controls.
Read-only.
The color of the stroke.
Sample code:
// Create a circle shaped path at { x: 50, y: 50 } with a radius of 10: var circle = new Path.Circle(new Point(50, 50), 10); // Set the stroke color of the circle to CMYK red: circle.strokeColor = new CMYKColor(1, 1, 0, 0);
The width of the stroke.
Sample code:
// Create a circle shaped path at { x: 50, y: 50 } with a radius of 10: var circle = new Path.Circle(new Point(50, 50), 10); // Set the stroke width of the circle to 3pt: circle.strokeWidth = 3;
The cap of the stroke.
Sample code:
// Create a line from { x: 0, y: 50 } to { x: 50, y: 50 }; var line = new Path.Line(new Point(0, 50), new Point(50, 50)); // Set the stroke cap of the line to be round: line.strokeCap = 'round';
The join of the stroke.
The dash offset of the stroke.
Specifies an array containing the dash and gap lengths of the stroke.
Sample code:
// Create a line from { x: 0, y: 50 } to { x: 50, y: 50 }; var line = new Path.Line(new Point(0, 50), new Point(50, 50)); line.strokeWidth = 3; // Set the dashed stroke to [10pt dash, 5pt gap, 8pt dash, 10pt gap]: line.dashArray = [10, 5, 8, 10];
The miter limit controls when the program switches from a mitered (pointed) join to a beveled (squared-off) join. The default miter limit is 4, which means that when the length of the point reaches four times the stroke weight, the program switches from a miter join to a bevel join. A miter limit of 0 results in a bevel join.
Specifies whether to overprint the stroke. By default, when you print opaque, overlapping colors, the top color knocks out the area underneath.
You can use overprinting to prevent knockout and make the topmost overlapping printing ink appear transparent in relation to the underlying ink.
Specifies whether to overprint the fill. By default, when you print opaque, overlapping colors, the top color knocks out the area underneath.
You can use overprinting to prevent knockout and make the topmost overlapping printing ink appear transparent in relation to the underlying ink.
The output resolution for the path.
Removes the item from the document. If the item has children, they are also removed.
Removes all the children items contained within the item.
Reverses the order of this item's children
Rasterizes the item into a newly created Raster object. The item itself is not removed after rasterization.
Checks if the item contains any children items.
Checks whether the item is editable.
Checks whether the item is valid, i.e. it hasn't been removed.
Sample code:
var path = new Path(); print(path.isValid()); // true path.remove(); print(path.isValid()); // false
Inserts the specified item as a child of the item by appending it to the list of children and moving it above all other children. You can use this function for groups, compound paths and layers.
Sample code:
var group = new Group(); var path = new Path(); group.appendTop(path); print(path.isDescendant(group)); // true
Inserts the specified item as a child of this item by appending it to the list of children and moving it below all other children. You can use this function for groups, compound paths and layers.
Sample code:
var group = new Group(); var path = new Path(); group.appendBottom(path); print(path.isDescendant(group)); // true
Moves this item above the specified item.
Sample code:
var firstPath = new Path(); var secondPath = new Path(); print(firstPath.isAbove(secondPath)); // false firstPath.moveAbove(secondPath); print(firstPath.isAbove(secondPath)); // true
Moves the item below the specified item.
Sample code:
var firstPath = new Path(); var secondPath = new Path(); print(secondPath.isBelow(firstPath)); // false secondPath.moveBelow(firstPath); print(secondPath.isBelow(firstPath)); // true
Checks if this item is above the specified item in the stacking order of the document.
Sample code:
var firstPath = new Path(); var secondPath = new Path(); print(secondPath.isAbove(firstPath)); // true
Checks if the item is below the specified item in the stacking order of the document.
Sample code:
var firstPath = new Path(); var secondPath = new Path(); print(firstPath.isBelow(secondPath)); // true
Checks if the item is contained within the specified item.
Sample code:
var group = new Group(); var path = new Path(); group.appendTop(path); print(path.isDescendant(group)); // true
Checks if the item is an ancestor of the specified item.
Sample code:
var group = new Group(); var path = new Path(); group.appendChild(path); print(group.isAncestor(path)); // true print(path.isAncestor(group)); // false
Checks whether the item is grouped with the specified item.
Scales the item by the given values from its center point, or optionally by a supplied point.
See also: matrix.scale(scaleX, scaleY[, center])
Scales the item by the given value from its center point, or optionally by a supplied point.
Sample code:
// Create a circle at position { x: 10, y: 10 } var circle = new Path.Circle(new Point(10, 10), 10); print(circle.bounds.width); // 20 // Scale the path by 200% around its center point circle.scale(2); print(circle.bounds.width); // 40
// Create a circle at position { x: 10, y: 10 } var circle = new Path.Circle(new Point(10, 10), 10); // Scale the path 200% from its bottom left corner circle.scale(2, circle.bounds.bottomLeft);
See also: matrix.scale(scale[, center])
Translates (moves) the item by the given offset point.
Sample code:
// Create a circle at position { x: 10, y: 10 } var circle = new Path.Circle(new Point(10, 10), 10); circle.translate(new Point(5, 10)); print(circle.position); // {x: 15, y: 20}Alternatively you can also add to the position of the item:
// Create a circle at position { x: 10, y: 10 } var circle = new Path.Circle(new Point(10, 10), 10); circle.position += new Point(5, 10); print(circle.position); // {x: 15, y: 20}
Rotates the item by a given angle around the given point.
Angles are oriented clockwise and measured in degrees by default. Read more about angle units and orientation in the description of the point.angle property.
See also: matrix.rotate(angle[, center])
Shears the item with a given amount around its center point.
See also: matrix.shear(shearX, shearY)
Transforms the item with custom flags to be set.
Rasterizes the passed items into a newly created Raster object. The items are not removed after rasterization.
Copyright © 2001-2011 Jürg Lehni, Scratchdisk.com. All Rights Reserved.