I'm trying to use paper.js with Dart through js.dart.
A lot seems to work, but I also need the method importSVG
from paper.js. When I try to access it with js.context.paper.project.importSVG(query("#svg"));
I get NoSuchMethodError
. It's somehow because the method is injected into project -- see code from paper.js below.
How do I access the importSVG
method from Dart?
/* paper.js */
new function() {
function importSVG(node, clearDefs) {
// ...
}
Item.inject(/** @lends Item# */{
/**
* Converts the passed node node into a Paper.js item and adds it to the
* children of this item.
*
* @param {SVGSVGElement} node the SVG DOM node to convert
* @return {Item} the converted Paper.js item
*/
importSVG: function(node) {
return this.addChild(importSVG(node, true));
}
});
Project.inject(/** @lends Project# */{
/**
* Converts the passed node node into a Paper.js item and adds it to the
* active layer of this project.
*
* @param {SVGSVGElement} node the SVG DOM node to convert
* @return {Item} the converted Paper.js item
*/
importSVG: function(node) {
this.activate();
return importSVG(node, true);
}
});
};
Your Dart call seems correct. The comments on the question tend to show that there's a problem with the javascript import/declaration of paper.project.importSVG
.