javascript - 如何在 JS 中指定路径的颜色属性(填充和描边)
问题描述
所以我试图在我的过程中优化一些设计,对于这个任务,我正在为 Illustrator 和 Photoshop 试验 javascript,我现在遇到的问题是绘制、填充和更改路径的笔触颜色。那么如何在 JS 中为 Illustrator 使用一组颜色来填充一种颜色的路径和另一种颜色的描边呢?
正确知道它只是采用我最后声明的 CMYK 颜色并忽略以前的颜色。
代码:
var RectangleColor = new CMYKColor();
RectangleColor.black = 0;
RectangleColor.cyan = 0;
RectangleColor.magenta = 0;
RectangleColor.yellow = 0;
var RectangleColorStroke = new CMYKColor();
RectangleColor.black = 0;
RectangleColor.cyan = 80;
RectangleColor.magenta = 80;
RectangleColor.yellow = 0;
并在绘图方法中
rect.filled = true;
rect.fillColor = RectangleColor;
rect.strokeColor = RectangleColorStroke;
注意:我真的不知道是否存在名为 的属性strokeColor
,但由于它没有显示任何错误,因此决定使用它。
解决方案
好吧,我知道这不是最干净的方法,但已经找到了方法。
声明了这个变量
var col = new GrayColor();
col.gray = 100;
在代码中有这个
var rect = artLayer.pathItems.rectangle (monthsCubeY,monthsCubeX,180,100); //draw rectangle at the selected coordenates
monthsCubeX = monthsCubeX + 190; //move the coordenates for the next rectangle
rect.filled = true;
rect.stroked = true;
strokeWidth = 1;
rect.fillColor = RectangleColor;
strokeColor = col;
我不太了解编码,但这似乎对我有用。
推荐阅读
- snowflake-cloud-data-platform - 雪花 - 我们可以将它托管在私有云中吗?
- sql - 我盯着这个 SQL 代码看了好几个小时,看不出问题可能只是愚蠢(Microsoft Access SQL)
- maven - 创建自定义处理器 apache nifi
- angular - 仅在通过 http 请求调用图像 url 时出现 cors 错误,但除此之外所有 api 都运行良好
- r - RStudio 保存 Rmd 文件非常慢
- business-process-management - IBM BPM Coach - 当十进制视图文本字段中存在空值时立即禁用按钮
- python - 使用 selenium Python 在 excel 中查找行号
- flutter - 断言失败:第 22 行 pos 14: 'url != null': is not true
- java - 来自 LinearLayout 的 getLayoutParams() 返回 null
- matlab - 将矩阵转换为单元格并将 NaN 替换为 '-'