【问题标题】:How do I make Paper.js package for Meteor work in Meteor.js?如何使 Meteor 的 Paper.js 包在 Meteor.js 中工作?
【发布时间】:2015-10-11 02:50:41
【问题描述】:

做完之后:meteor add marcinn:paperjs.

它产生一个错误,因为路径没有定义(framePreview.js 中的 paperjs Path() 函数)

缺少什么(paper.js 存在于包和包列表文件中)

这是我的测试:

---tsite01.html (stands for test site 01)

<head>
<title>tsite01</title>
<!-- Load the Paper.js library--> 
<script type="text/paperscript" src="papers/framePreview.js" canvas="framePreview"> </script>
</head>

<body>
  <h1>Hello World!</h1>
  {{> hello}}   
  <canvas id="framePreview" resize></canvas>
</body>


<template name="hello">
  <button>Click here</button>
  <p>You've pressed the bouton {{counter}} times.</p>
</template>

--- framePreview.js  in papers subdirectory

var path=new Path();
path.strokeColor='black';
var start= new Point(100,100);
path.moveTo(start);
path.lineTo(start+[10,-50]);

-- tsite.js

if (Meteor.isClient) {
  // counter starts at 0
  Session.setDefault('counter', 0);

  Template.hello.helpers({
    counter: function () {
      return Session.get('counter');
    }
  });

  Template.hello.events({
    'click button': function () {
      // increment the counter when button is clicked
      Session.set('counter', Session.get('counter') + 1);
    }
  });
}

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}

【问题讨论】:

  • Meteor 包安装在~/.meteor/packages。这个包应该出现在~/.meteor/packages/marcinn_paperjs

标签: meteor paperjs


【解决方案1】:

要让 paper.js 在 Meteor 中工作,需要在窗口中显示 paper 函数(包装整个库)。

如果这个包对你有帮助,请告诉我:

https://github.com/maddymaxey/Paperjs

要使用它,请确保一切都用纸调用。例如:new paper.Point 而不是 new Point。

【讨论】:

  • 您的回答不完整。您应该添加更多信息以使其自包含
猜你喜欢
  • 1970-01-01
  • 2018-10-07
  • 1970-01-01
  • 2014-03-29
  • 1970-01-01
  • 1970-01-01
  • 2013-09-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多