专色
app.activeDocument.spots
文档中的 SpotColor 对象集合。
Spots.length
Section titled “Spots.length”app.activeDocument.spots.length
集合中的元素数量。
数字;只读。
Spots.parent
Section titled “Spots.parent”app.activeDocument.spots.parent
对象的容器。
对象;只读。
Spots.typename
Section titled “Spots.typename”app.activeDocument.spots.typename
对象的类名。
字符串;只读。
Spots.add()
Section titled “Spots.add()”app.activeDocument.spots.add()
创建一个新对象。
Spots.getByName()
Section titled “Spots.getByName()”app.activeDocument.spots.getByName(name)
获取集合中具有指定名称的第一个元素。
参数 | 类型 | 描述 |
---|---|---|
name | 字符串 | 要获取的元素的名称 |
Spots.index()
Section titled “Spots.index()”app.activeDocument.spots.index(itemKey)
从集合中获取一个元素。
参数 | 类型 | 描述 |
---|---|---|
itemKey | 字符串, 数字 | 要获取的元素的键 |
Spots.removeAll()
Section titled “Spots.removeAll()”app.activeDocument.spots.removeAll()
删除集合中的所有元素。
无。
// 从当前文档中删除所有专色if ( app.documents.length > 0 ) { var spotCount = app.activeDocument.spots.length;
if (spotCount > 0) { app.activeDocument.spots.removeAll(); }}
创建并应用专色
Section titled “创建并应用专色”// 在当前文档中定义并应用一个新的专色,// 然后将该颜色应用到第一个路径项if (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) { // 定义新的颜色值 var newRGBColor = new RGBColor(); newRGBColor.red = 255; newRGBColor.green = 0; newRGBColor.blue = 0;
// 创建新的专色 var newSpot = app.activeDocument.spots.add();
// 将新的 SpotColor 定义为 RGB 颜色的 80% newSpot.name = "Scripted Red spot"; newSpot.tint = 80; newSpot.color = newRGBColor;
// 将新专色的 50% 色调应用到最前面的路径项。 // 创建一个 spotcolor 对象,设置色调值, var newSpotColor = new SpotColor(); newSpotColor.spot = newSpot; newSpotColor.tint = 50;
// 使用专色设置填充颜色 var frontPath = app.activeDocument.pathItems[0]; frontPath.filled = true; frontPath.fillColor = newSpotColor;}