0

js.dartを介してDartでpaper.jsを使用しようとしています。

多くのことが機能しているように見えますが、importSVGpaper.js のメソッドも必要です。でアクセスしようとすると、 が表示されjs.context.paper.project.importSVG(query("#svg"));ますNoSuchMethodError。メソッドがプロジェクトに挿入されているためです。以下の paper.js のコードを参照してください。

importSVGDart からメソッドにアクセスするにはどうすればよいですか?

/* 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);
            }
    });
};
4

2 に答える 2

0

Dart コールは正しいようです。質問へのコメントは、JavaScript のインポート/宣言に問題があることを示す傾向がありpaper.project.importSVGます。

于 2013-06-24T13:32:53.000 に答える