第一个使用XD的插件,我似乎不能创建一个Color类的实例。
他们的文档没有显示任何示例,我在其他示例中找到的任何示例都只显示了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
}
};发布于 2019-11-21 05:05:22
在深入研究了同一“命名空间”中的其他类之后,发现它们的文档在某些地方是完全错误的。这就是它应该是的。
const Color = require("scenegraph").Color;
let color = new Color('#FF00CD');这恰好与文档中使用Color的示例直接矛盾。太棒了,免费的代码!
https://stackoverflow.com/questions/58937493
复制相似问题