PathItem
PathItem
Section titled “PathItem”app.activeDocument.pathItems[index]
指定一个路径项,其中包含定义其几何形状的 PathPoint 对象。
PathItem
类提供了对 Illustrator 中路径的完全访问。
setEntirePath
方法提供了一种非常高效的方式来创建由直线组成的路径。
PathItem.area
Section titled “PathItem.area”app.activeDocument.pathItems[index].area
该路径的面积(以平方点为单位)。
如果面积为负,则路径是逆时针方向的。
自相交路径可能包含相互抵消的子区域,这使得即使路径有明显的面积,该值也可能为零。
Number (double);只读。
PathItem.artworkKnockout
Section titled “PathItem.artworkKnockout”app.activeDocument.pathItems[index].artworkKnockout
此对象是否用于创建挖空效果,如果是,挖空类型是什么。
PathItem.blendingMode
Section titled “PathItem.blendingMode”app.activeDocument.pathItems[index].blendingMode
合成对象时使用的混合模式。
PathItem.clipping
Section titled “PathItem.clipping”app.activeDocument.pathItems[index].clipping
如果为 true
,此路径应作为剪切路径使用。
Boolean
PathItem.closed
Section titled “PathItem.closed”app.activeDocument.pathItems[index].closed
如果为 true
,此路径是闭合的。
Boolean
PathItem.controlBounds
Section titled “PathItem.controlBounds”app.activeDocument.pathItems[index].controlBounds
对象的边界,包括描边宽度和控件。
4 个数字的数组;只读。
PathItem.editable
Section titled “PathItem.editable”app.activeDocument.pathItems[index].editable
如果为 true
,此项目是可编辑的。
Boolean;只读。
PathItem.evenodd
Section titled “PathItem.evenodd”app.activeDocument.pathItems[index].evenodd
如果为 true
,应使用奇偶规则来确定“内部”。
Boolean
PathItem.fillColor
Section titled “PathItem.fillColor”app.activeDocument.pathItems[index].fillColor
路径的填充颜色。
PathItem.filled
Section titled “PathItem.filled”app.activeDocument.pathItems[index].filled
如果为 true
,路径被填充。
Boolean
PathItem.fillOverprint
Section titled “PathItem.fillOverprint”app.activeDocument.pathItems[index].fillOverprint
如果为 true
,填充对象下方的图稿应进行叠印。
Boolean
PathItem.geometricBounds
Section titled “PathItem.geometricBounds”app.activeDocument.pathItems[index].geometricBounds
对象的边界,不包括描边宽度。
4 个数字的数组;只读。
PathItem.guides
Section titled “PathItem.guides”app.activeDocument.pathItems[index].guides
如果为 true
,此路径是参考线对象。
Boolean
PathItem.height
Section titled “PathItem.height”app.activeDocument.pathItems[index].height
组项目的高度。
Number (double)
PathItem.hidden
Section titled “PathItem.hidden”app.activeDocument.pathItems[index].hidden
如果为 true
,此项目是隐藏的。
Boolean
PathItem.isIsolated
Section titled “PathItem.isIsolated”app.activeDocument.pathItems[index].isIsolated
如果为 true
,此对象是隔离的。
Boolean
PathItem.layer
Section titled “PathItem.layer”app.activeDocument.pathItems[index].layer
此项目所属的图层。
Layer;只读。
PathItem.left
Section titled “PathItem.left”app.activeDocument.pathItems[index].left
项目左侧的位置(以点为单位,从页面左侧测量)。
Number (double)
PathItem.length
Section titled “PathItem.length”app.activeDocument.pathItems[index].length
此路径的长度(以点为单位)。
Number (double)
PathItem.locked
Section titled “PathItem.locked”app.activeDocument.pathItems[index].locked
如果为 true
,此项目是锁定的。
Boolean
PathItem.name
Section titled “PathItem.name”app.activeDocument.pathItems[index].name
此项目的名称。
String
PathItem.note
Section titled “PathItem.note”app.activeDocument.pathItems[index].note
分配给此项目的注释。
String
PathItem.opacity
Section titled “PathItem.opacity”app.activeDocument.pathItems[index].opacity
对象的不透明度。
范围:0.0 到 100.0
Number (double)
PathItem.parent
Section titled “PathItem.parent”app.activeDocument.pathItems[index].parent
此对象的父对象。
PathItem.pathPoints
Section titled “PathItem.pathPoints”app.activeDocument.pathItems[index].pathPoints
此路径项中包含的路径点。
PathPoints;只读。
PathItem.pixelAligned
Section titled “PathItem.pixelAligned”app.activeDocument.pathItems[index].pixelAligned
如果为 true
,此项目对齐到像素网格。
Boolean
PathItem.polarity
Section titled “PathItem.polarity”app.activeDocument.pathItems[index].polarity
路径的极性。
PathItem.position
Section titled “PathItem.position”app.activeDocument.pathItems[index].position
pluginItem
对象左上角的位置(以点为单位),格式为 [x, y]。不包括描边宽度。
2 个数字的数组;只读。
PathItem.resolution
Section titled “PathItem.resolution”app.activeDocument.pathItems[index].resolution
路径的分辨率(以每英寸点数 (dpi) 为单位)。
Number (double)
PathItem.selected
Section titled “PathItem.selected”app.activeDocument.pathItems[index].selected
如果为 true
,此项目被选中。
Boolean
PathItem.selectedPathPoints
Section titled “PathItem.selectedPathPoints”app.activeDocument.pathItems[index].selectedPathPoints
路径中所有选中的路径点。
PathPoints;只读。
PathItem.sliced
Section titled “PathItem.sliced”app.activeDocument.pathItems[index].sliced
如果为 true
,项目被切片。
默认值:false
Boolean
PathItem.strokeCap
Section titled “PathItem.strokeCap”app.activeDocument.pathItems[index].strokeCap
线帽的类型。
PathItem.strokeColor
Section titled “PathItem.strokeColor”app.activeDocument.pathItems[index].strokeColor
路径的描边颜色。
PathItem.stroked
Section titled “PathItem.stroked”app.activeDocument.pathItems[index].stroked
如果为 true
,路径应描边。
Boolean
PathItem.strokeDashes
Section titled “PathItem.strokeDashes”app.activeDocument.pathItems[index].strokeDashes
虚线长度。设置为空对象 {}
表示实线。
Object
PathItem.strokeDashOffset
Section titled “PathItem.strokeDashOffset”app.activeDocument.pathItems[index].strokeDashOffset
虚线图案中默认开始的距离。
Number (double)
PathItem.strokeJoin
Section titled “PathItem.strokeJoin”app.activeDocument.pathItems[index].strokeJoin
路径的连接类型。
PathItem.strokeMiterLimit
Section titled “PathItem.strokeMiterLimit”app.activeDocument.pathItems[index].strokeMiterLimit
当默认描边连接设置为斜接时,此属性指定何时将连接转换为斜切(方形)。默认的斜接限制为 4 表示当点的长度达到描边宽度的四倍时,连接将从斜接连接转换为斜切连接。值为 1 表示斜切连接。
范围:1 到 500。
默认值:4
Number (double)
PathItem.strokeOverprint
Section titled “PathItem.strokeOverprint”app.activeDocument.pathItems[index].strokeOverprint
如果为 true
,描边对象下方的图稿应进行叠印。
Boolean
PathItem.strokeWidth
Section titled “PathItem.strokeWidth”app.activeDocument.pathItems[index].strokeWidth
描边的宽度(以点为单位)。
Number (double)
PathItem.tags
Section titled “PathItem.tags”app.activeDocument.pathItems[index].tags
此项目中包含的标签。
Tags;只读。
PathItem.top
Section titled “PathItem.top”app.activeDocument.pathItems[index].top
项目顶部的位置(以点为单位,从页面底部测量)。
Number (double)
PathItem.typename
Section titled “PathItem.typename”app.activeDocument.pathItems[index].typename
引用对象的类名。
String;只读。
PathItem.uRL
Section titled “PathItem.uRL”app.activeDocument.pathItems[index].uRL
分配给此项目的 Adobe URL 标签的值。
String
PathItem.visibilityVariable
Section titled “PathItem.visibilityVariable”app.activeDocument.pathItems[index].visibilityVariable
绑定到项目的可见性变量。
PathItem.visibleBounds
Section titled “PathItem.visibleBounds”app.activeDocument.pathItems[index].visibleBounds
项目的可见边界,包括描边宽度。
4 个数字的数组;只读。
PathItem.width
Section titled “PathItem.width”app.activeDocument.pathItems[index].width
项目的宽度。
Number (double)
PathItem.wrapInside
Section titled “PathItem.wrapInside”app.activeDocument.pathItems[index].wrapInside
如果为 true
,文本框架对象应在此对象内部换行。
Boolean
PathItem.wrapOffset
Section titled “PathItem.wrapOffset”app.activeDocument.pathItems[index].wrapOffset
围绕此对象换行文本时使用的偏移量。
Number (double)
PathItem.wrapped
Section titled “PathItem.wrapped”app.activeDocument.pathItems[index].wrapped
如果为 true
,围绕此对象换行文本框架对象(文本框架必须位于对象上方)。
Boolean
PathItem.zOrderPosition
Section titled “PathItem.zOrderPosition”app.activeDocument.pathItems[index].zOrderPosition
此项目在包含该项目的组或图层(parent
)中的堆叠顺序中的位置。
Number;只读。
PathItem.duplicate()
Section titled “PathItem.duplicate()”app.activeDocument.pathItems[index].duplicate([relativeObject][, insertionLocation])
创建所选对象的副本。
参数 | 类型 | 描述 |
---|---|---|
relativeObject | Object, 可选 | 要复制到的对象 |
insertionLocation | ElementPlacement, 可选 | 插入元素的位置 |
PathItem.move()
Section titled “PathItem.move()”app.activeDocument.pathItems[index].move(relativeObject, insertionLocation)
移动对象。
参数 | 类型 | 描述 |
---|---|---|
relativeObject | Object | 要移动元素的对象 |
insertionLocation | ElementPlacement, 可选 | 移动元素到的位置 |
PathItem.remove()
Section titled “PathItem.remove()”app.activeDocument.pathItems[index].remove()
删除此对象。
无。
PathItem.resize()
Section titled “PathItem.resize()”app.activeDocument.pathItems[index].resize( scaleX, scaleY [,changePositions] [,changeFillPatterns] [,changeFillGradients] [,changeStrokePattern] [,changeLineWidths] [,scaleAbout])
缩放图稿项,其中 scaleX
是水平缩放因子,scaleY
是垂直缩放因子。100.0 = 100%。
参数 | 类型 | 描述 |
---|---|---|
scaleX | Number (double) | 水平缩放因子 |
scaleY | Number (double) | 垂直缩放因子 |
changePositions | Boolean, 可选 | 是否影响图稿对象的位置和方向 |
changeFillPatterns | Boolean, 可选 | 是否变换填充图案 |
changeFillGradients | Boolean, 可选 | 是否变换填充渐变 |
changeStrokePattern | Boolean, 可选 | 是否变换描边图案 |
changeLineWidths | Number (double), 可选 | 缩放线宽的量 |
scaleAbout | Transformation, 可选 | 用作锚点的点,用于变换 |
无。
PathItem.rotate()
Section titled “PathItem.rotate()”app.activeDocument.pathItems[index].rotate( angle [,changePositions] [,changeFillPatterns] [,changeFillGradients] [,changeStrokePattern] [,rotateAbout])
相对于当前旋转角度旋转图稿项。
如果 angle
值为正,则对象逆时针旋转;如果值为负,则顺时针旋转。
参数 | 类型 | 描述 |
---|---|---|
angle | Number (double) | 旋转元素的角度量 |
changePositions | Boolean, 可选 | 是否影响图稿对象的位置和方向 |
changeFillPatterns | Boolean, 可选 | 是否变换填充图案 |
changeFillGradients | Boolean, 可选 | 是否变换填充渐变 |
changeStrokePattern | Boolean, 可选 | 是否变换描边图案 |
rotateAbout | Transformation, 可选 | 用作锚点的点,用于变换 |
无。
PathItem.setEntirePath()
Section titled “PathItem.setEntirePath()”app.activeDocument.pathItems[index].setEntirePath(pathPoints)
使用 [x, y] 坐标对的数组设置路径。
参数 | 类型 | 描述 |
---|---|---|
pathPoints | [x, y] 坐标对的数组 | 要设置的点坐标数组 |
无。
PathItem.transform()
Section titled “PathItem.transform()”app.activeDocument.pathItems[index].transform( transformationMatrix [, changePositions] [, changeFillPatterns] [, changeFillGradients] [, changeStrokePattern] [, changeLineWidths] [, transformAbout])
通过应用变换矩阵来变换图稿项。
参数 | 类型 | 描述 |
---|---|---|
transformationMatrix | Matrix | 要应用的变换矩阵 |
changePositions | Boolean, 可选 | 是否更改位置 |
changeFillPatterns | Boolean, 可选 | 是否更改填充图案 |
changeFillGradients | Boolean, 可选 | 是否更改填充渐变 |
changeStrokePattern | Boolean, 可选 | 是否更改描边图案 |
changeLineWidths | Number (double), 可选 | 缩放线宽的量 |
transformAbout | Transformation, 可选 | 用作锚点的点,用于变换 |
无。
PathItem.translate()
Section titled “PathItem.translate()”app.activeDocument.pathItems[index].translate( [deltaX] [, deltaY] [, transformObjects] [, transformFillPatterns] [, transformFillGradients] [, transformStrokePatterns])
相对于当前位置重新定位图稿项,其中 deltaX
是水平偏移量,deltaY
是垂直偏移量。
参数 | 类型 | 描述 |
---|---|---|
deltaX | Number (double), 可选 | 水平偏移量 |
deltaY | Number (double), 可选 | 垂直偏移量 |
transformObjects | Boolean, 可选 | 是否变换对象 |
transformFillPatterns | Boolean, 可选 | 是否变换填充图案 |
transformFillGradients | Boolean, 可选 | 是否变换填充渐变 |
transformStrokePatterns | Boolean, 可选 | 是否变换描边图案 |
无。
PathItem.zOrder()
Section titled “PathItem.zOrder()”app.activeDocument.pathItems[index].zOrder(zOrderCmd)
在组或图层(父对象)的堆叠顺序中排列图稿项的位置。
参数 | 类型 | 描述 |
---|---|---|
zOrderCmd | ZOrderMethod | 堆叠顺序排列方法 |
无。
设置路径中的颜色
Section titled “设置路径中的颜色”// 将路径项的描边和填充设置为随机选择的色板的颜色if (app.documents.length > 0 && app.activeDocument.pathItems.length > 0) { var doc = app.activeDocument;
for (var i = 0; i < doc.pathItems.length; i++) { var pathRef = doc.pathItems[i]; pathRef.filled = true; pathRef.stroked = true;
var swatchIndex = Math.round(Math.random() * (doc.swatches.length - 1)); pathRef.fillColor = doc.swatches[swatchIndex].color; pathRef.strokeColor = doc.swatches[swatchIndex].color; }}
用直线创造路径
Section titled “用直线创造路径”// 此脚本演示了 setEntirePath 方法的使用。// 创建一个由10条直线组成的新开放路径if (app.documents.length > 0) { var lineList = [];
for (i = 0; i < lineList.length; i++) { lineList.push([i * 10 + 50, ((i - 5) ^ 2) * 5 + 50]; }
app.defaultStroked = true; newPath = app.activeDocument.pathItems.add(); newPath.setEntirePath(lineList);}