Skip to content

PatternColor

patternColor

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.


patternColor.matrix

Additional transformation arising from manipulating the path.

Matrix


patternColor.pattern

A reference to the pattern object that defines the pattern to use in this color definition.

Pattern


patternColor.reflect

If true, the prototype should be reflected before filling.

Default: false

Boolean


patternColor.reflectAngle

The axis around which to reflect, in points.

Default: 0.0

Number (double)


patternColor.rotation

The angle in radians to rotate the prototype pattern before filling.

Default: 0.0

Number (double)


patternColor.scaleFactor

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

The angle in radians by which to slant the shear.

Default: 0.0

Number (double)


patternColor.shearAxis

The axis to shear with respect to, in points.

Default: 0.0

Number (double)


patternColor.shiftAngle

The angle in radians to which to translate the unscaled prototype pattern before filling.

Default: 0.0

Number (double)


patternColor.shiftDistance

The distance in points to which to translate the unscaled prototype pattern before filling.

Default: 0.0

Number (double)


patternColor.typename

The class name of the referenced object.

String; read-only.


// Rotates the color of each pattern in the current document,
// then applies the last pattern to the first path item
if (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;
}