javascript - Illustrator插件区

标签 javascript plugins adobe-illustrator

我想知道以下代码中的 .area 到底给了我什么:

alert("Area & Length \nArea: " + (Math.abs(app.activeDocument.selection[0].area).toFixed(3)) + "\nLength: " + (app.activeDocument.selection[0].length).toFixed(3));

我知道它给了我一个区域,但是以什么单位(像素?)。原始代码将面积值除以5184(72*72),这应该是ppi值。该文档不包含任何内容:

http://www.adobe.com/devnet/illustrator/scripting.html

感谢您的宝贵时间。

最佳答案

谢谢你的提问,到目前为止我还不知道Illustrator中是否存在长度和面积属性。我弄清楚它们是什么

如果所选项目是

矩形

var w = app.activeDocument.selection[0].width;
var h = app.activeDocument.selection[0].height;
var length = w + w + h + h;
var area = w * h;

对于椭圆/圆

var r = (app.activeDocument.selection[0].width);
var area = π * r * r = 3.14 * r * r;
var length = 2 * pie * r = 2 * 3.14 * r;

基本上,它与数学类似,它根据所选对象的形状使用面积和周长(长度)。这里的 π 是我们在数学中使用的。

希望这对您有帮助。

关于javascript - Illustrator插件区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40611679/

相关文章:

android - iOS 将 Cordova 应用程序作为 webview 嵌入到另一个应用程序中

shell - 在 cakephp 2.0 中运行插件的 shell

c++ - apple mach o 链接器错误创建基本 AI CC 插件

javascript - 如何在单击按钮时使图像旋转

javascript - jQuery 在第二次刷新之前不会加载数据

javascript - 使用 jquery 禁用验证中的提交按钮

javascript - SVG for Web 中的长阴影效果

javascript - "import"assetic的依赖解决方案

plugins - 基本插件 (NPAPI/npruntime) Hello world

svg - 此 SVG 无效。在打开之前验证它