开始方法
// 获取当前文档
var doc = app.activeDocument;
创建新文档
app.documents.add([documentColorSpace] [, width] [, height] [, numArtBoards] [, artboardLayout] [, artboardSpacing] [, artboardRowsOrCols])
举例:
//创建新文档
var doc = app.documents.add();
//创建新文档,并定义颜色空间为RGB
var doc = app.documents.add(DocumentColorSpace.RGB);
//创建新文档,并定义颜色空间为RGB,长宽为500,500。单位为pt
var doc = app.documents.add(DocumentColorSpace.RGB,500,500);
参数 | 类型 | 描述 |
---|---|---|
| 文档的色彩空间 | |
| 数字(双精度),可选 | 文档宽度为add |
| 数字(双精度),可选 | 文档高度add |
| 数字(长),可选 | 要创建的画板数 |
| 文档画板布局,可选 | 画板布局 |
| 编号,可选 | 间距的像素数 |
| 整数,可选 | 行数或列数 |
创建形状的常用方法
PathItems
ai 的路径类常用方法
PathItems.ellipse()
使用提供的参数创建一个新的椭圆形 pathItem。
app.activeDocument.pathItems.ellipse([top][, left][, width][, height][, reversed][, inscribed])
默认值
参数 | 值 |
---|---|
| 100 pt. |
| 100 pt. |
| 50 pt. |
| 100 pt. |
| false |
参数
参数 | 类型 | 描述 |
---|---|---|
| 数字(双精度),可选 | 路径顶部 |
| 数字(双精度),可选 | 路径左侧 |
| 数字(双精度),可选 | 路径宽度 |
| 数字(双精度),可选 | 路径高度 |
| 布尔值,可选 | 路径是否反转 |
| 布尔值,可选 | 路径是否被写入 |
返回值:PathItem
PathItems.polygon()
app.activeDocument.pathItems.polygon([centerX][, centerY][, radius][, sides][, reversed])
使用提供的参数创建多边形形状的新路径项。
默认值
参数 | 值 |
---|---|
| 200 pt. |
| 300 pt. |
| 50 pt. |
| 8 |
| false |
参数 | 类型 | 描述 |
---|---|---|
| 数字(双精度),可选 | 路径的中心 X |
| 数字(双精度),可选 | 路径的中心 Y |
| 数字(双精度),可选 | 路径半径 |
| 数字(长),可选 | 边数 |
| 布尔值,可选 | 路径是否反转 |
返回值:PathItem
PathItems.rectangle()
app.activeDocument.pathItems.rectangle(top, left, width, height[,reversed])
描述
使用提供的参数创建多边形形状的新多边形。pathItem
参数
参数 | 类型 | 描述 |
---|---|---|
| 数量(双精度) | 路径顶部 |
| 数量(双精度) | 路径左侧 |
| 数量(双精度) | 路径宽度 |
| 数量(双精度) | 路径高度 |
| 布尔值,可选 | 路径是否反转 |
返回值:PathItem
PathItems.roundedRectangle()
app.activeDocument.pathItems.roundedRectangle(top, left, width, height[, horizontalRadius][, verticalRadius][, reversed])
描述
使用提供的参数创建具有圆角的矩形形状的新路径项。
违约
参数 | 值 |
---|---|
| 15 pt |
| 20 pt |
| false |
参数 | 类型 | 描述 |
---|---|---|
| 数量(双精度) | 路径顶部 |
| 数量(双精度) | 路径左侧 |
| 数量(双精度) | 路径宽度 |
| 数量(双精度) | 路径高度 |
| 数字(双精度),可选 | 圆角的水平半径 |
| 数字(双精度),可选 | 圆角的垂直半径 |
| 布尔值,可选 | 路径是否反转 |
PathItems.star()
app.activeDocument.pathItems.star([centerX][, centerY][, radius][, innerRadius][, points][, reversed])
描述:使用提供的参数创建星形的新路径项。
默认值
参数 | 值 |
---|---|
| 200 pt. |
| 300 pt. |
| 50 pt. |
| 20 pt. |
| 5 |
| false |
参数 | 类型 | 描述 |
---|---|---|
| 数字(双精度),可选 | 路径的中心 X |
| 数字(双精度),可选 | 路径的中心 Y |
| 数字(双精度),可选 | 路径半径 |
| 数字(双精度),可选 | 路径内半径 |
| 数字(长),可选 | 点数 |
| 布尔值,可选 | 路径是否反转 |
返回值:PathItem
PathItems.removeAll()
app.activeDocument.pathItems.removeAll()
描述
删除此集合中的所有元素。
返回
无