Plugin ReferenceError: Color is not defined in
Plugin ReferenceError: Color is not defined in
第一个带有 XD 的插件,我似乎无法创建 class 颜色的实例。
他们的文档没有显示任何示例,我在其他示例中找到的任何示例仅显示 new Color()
并且我不必执行任何 require
.
https://adobexdplatform.com/plugin-docs/reference/Color.html
Plugin ReferenceError: Color is not defined
at exportToBmpFunction (C:\Users\<useR>\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState\develop\BMP_Export\main.js:21:21)
我做错了什么?
async function exportToBmpFunction(selection) {
if (selection.items.length == 0) {
return;
}
// Generate PNG rendition of the selected node
let application = require("application");
let scenegraph = require("scenegraph");
let fs = require("uxp").storage.localFileSystem;
let shape = selection.items[0];
let file = await fs.getFileForSaving('what.png', { types: ["png"] });
let renditions = [{
node: shape,
outputFile: file,
type: application.RenditionType.PNG,
scale: 1,
background: new Color('#FF00CD', 1)
}];
application.createRenditions(renditions).then(function(results) {
// ...do something with outputFiles on disk...
});
}
module.exports = {
commands: {
exportToBmp: exportToBmpFunction
}
};
在同一个 'namespace' 中挖掘其他 类 后发现他们的文档在某些地方完全错误。这是应该的。
const Color = require("scenegraph").Color;
let color = new Color('#FF00CD');
这恰好与文档中使用 Color
的示例直接矛盾。
写手写代码太棒了!
第一个带有 XD 的插件,我似乎无法创建 class 颜色的实例。
他们的文档没有显示任何示例,我在其他示例中找到的任何示例仅显示 new Color()
并且我不必执行任何 require
.
https://adobexdplatform.com/plugin-docs/reference/Color.html
Plugin ReferenceError: Color is not defined
at exportToBmpFunction (C:\Users\<useR>\AppData\Local\Packages\Adobe.CC.XD_adky2gkssdxte\LocalState\develop\BMP_Export\main.js:21:21)
我做错了什么?
async function exportToBmpFunction(selection) {
if (selection.items.length == 0) {
return;
}
// Generate PNG rendition of the selected node
let application = require("application");
let scenegraph = require("scenegraph");
let fs = require("uxp").storage.localFileSystem;
let shape = selection.items[0];
let file = await fs.getFileForSaving('what.png', { types: ["png"] });
let renditions = [{
node: shape,
outputFile: file,
type: application.RenditionType.PNG,
scale: 1,
background: new Color('#FF00CD', 1)
}];
application.createRenditions(renditions).then(function(results) {
// ...do something with outputFiles on disk...
});
}
module.exports = {
commands: {
exportToBmp: exportToBmpFunction
}
};
在同一个 'namespace' 中挖掘其他 类 后发现他们的文档在某些地方完全错误。这是应该的。
const Color = require("scenegraph").Color;
let color = new Color('#FF00CD');
这恰好与文档中使用 Color
的示例直接矛盾。
写手写代码太棒了!