PatternColor
PatternColor
Section titled “PatternColor”patternColor
Description
Section titled “Description”A pattern color specification. You can create a new pattern color by modifying an existing pattern in the document. Any modification you make to a pattern affects that pattern in the Palette.
PatternColor
objects can be used in any property that takes a color object, such as fillColor
or strokeColor
.
Properties
Section titled “Properties”PatternColor.matrix
Section titled “PatternColor.matrix”patternColor.matrix
Description
Section titled “Description”Additional transformation arising from manipulating the path.
PatternColor.pattern
Section titled “PatternColor.pattern”patternColor.pattern
Description
Section titled “Description”A reference to the pattern object that defines the pattern to use in this color definition.
PatternColor.reflect
Section titled “PatternColor.reflect”patternColor.reflect
Description
Section titled “Description”If true
, the prototype should be reflected before filling.
Default: false
Boolean
PatternColor.reflectAngle
Section titled “PatternColor.reflectAngle”patternColor.reflectAngle
Description
Section titled “Description”The axis around which to reflect, in points.
Default: 0.0
Number (double)
PatternColor.rotation
Section titled “PatternColor.rotation”patternColor.rotation
Description
Section titled “Description”The angle in radians to rotate the prototype pattern before filling.
Default: 0.0
Number (double)
PatternColor.scaleFactor
Section titled “PatternColor.scaleFactor”patternColor.scaleFactor
Description
Section titled “Description”The fraction to which to scale the prototype pattern before filling, represented as a point containing horizontal and vertical scaling percentages.
Array of 2 numbers
PatternColor.shearAngle
Section titled “PatternColor.shearAngle”patternColor.shearAngle
Description
Section titled “Description”The angle in radians by which to slant the shear.
Default: 0.0
Number (double)
PatternColor.shearAxis
Section titled “PatternColor.shearAxis”patternColor.shearAxis
Description
Section titled “Description”The axis to shear with respect to, in points.
Default: 0.0
Number (double)
PatternColor.shiftAngle
Section titled “PatternColor.shiftAngle”patternColor.shiftAngle
Description
Section titled “Description”The angle in radians to which to translate the unscaled prototype pattern before filling.
Default: 0.0
Number (double)
PatternColor.shiftDistance
Section titled “PatternColor.shiftDistance”patternColor.shiftDistance
Description
Section titled “Description”The distance in points to which to translate the unscaled prototype pattern before filling.
Default: 0.0
Number (double)
PatternColor.typename
Section titled “PatternColor.typename”patternColor.typename
Description
Section titled “Description”The class name of the referenced object.
String; read-only.
Example
Section titled “Example”Modifying and applying pattern colors
Section titled “Modifying and applying pattern colors”// Rotates the color of each pattern in the current document,// then applies the last pattern to the first path itemif (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) { var doc = app.activeDocument; var swatchIndex = 0;
for (i = 0; i < doc.swatches.length; i++) { // Get the generic color object of the swatch var currentSwatch = doc.swatches[i]; var swatchColor = currentSwatch.color;
// Only operate on patterns if (currentSwatch.color.typename == "PatternColor") { // Change a pattern property currentSwatch.color.rotation = 10; swatchIndex = i; } }
// Apply the last pattern color swatch to the frontmost path var firstPath = app.activeDocument.pathItems[0]; firstPath.filled = true; firstPath.fillColor = doc.swatches[swatchIndex].color;}