如何在Meteor.js中为Meteor工作制作Paper.js包?

时间:2015-07-21 14:56:22

标签: meteor paperjs

之后:meteor add marcinn:paperjs。

它生成错误,因为未定义Path(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
  });
}

1 个答案:

答案 0 :(得分:0)

为了使paper.js在Meteor中工作,需要在窗口中显示纸质功能(包装整个库)。

如果此套餐可以帮助您,请告诉我:

https://github.com/maddymaxey/Paperjs

要使用它,请确保用纸张调用所有内容。例如:new paper.Point而不是新的Point。