Swatch
Swatch
Section titled “Swatch”app.activeDocument.swatches[index]
Description
Section titled “Description”A color swatch definition contained in a document. The swatches correspond to the swatch palette in the Illustrator user interface.
A script can create a new swatch.
The swatch can hold all types of color data, such as pattern, gradient, CMYK, RGB, gray, and spot.
Properties
Section titled “Properties”Swatch.color
Section titled “Swatch.color”app.activeDocument.swatches[index].color
Description
Section titled “Description”The color information for this swatch.
Swatch.name
Section titled “Swatch.name”app.activeDocument.swatches[index].name
Description
Section titled “Description”The swatch’s name.
String.
Swatch.parent
Section titled “Swatch.parent”app.activeDocument.swatches[index].parent
Description
Section titled “Description”The object that contains this swatch.
Document; read-only.
Swatch.typename
Section titled “Swatch.typename”app.activeDocument.swatches[index].typename
Description
Section titled “Description”The class name of the object.
String; read-only.
Methods
Section titled “Methods”Swatch.remove()
Section titled “Swatch.remove()”app.activeDocument.swatches[index].remove()
Description
Section titled “Description”Deletes this object.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Modifying a swatch
Section titled “Modifying a swatch”// Changes the name of the last swatchif ( app.documents.length > 0 && app.activeDocument.swatches.length > 0 ) { var lastIndex = app.activeDocument.swatches.length - 1; var lastSwatch = app.activeDocument.swatches[lastIndex]; lastSwatch.name = "TheLastSwatch";}