admin管理员组文章数量:1023838
i'm trying to learn some paper.js, and its onFrame event doesn't work with me :( In code below i create 30 random shapes on canvas, and trying to rotate each one of them by onFrame method, but nothing is happening, paths stand fixed.
var len = 30;
var array = new Array();
var rand;
var colors = ['#fbff00', '#99ff37', '#00eeff', '#374afe', '#ff005e'];
for(var i = 0; i < len; i++) {
rand = getRandom(0, 4);
switch (rand) {
case 0: // if 0, create circle
var path = new Path.Circle({
center: [getRandom(30, scrwidth - 30), getRandom(30, scrheight - 30)],
radius: 30
});
path.fillColor = colors[getRandom(0, 4)];
array.push(path);
break;
//and some others in the same way
}
}
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function onFrame(event) {
for (var i = 0; i < len; i++) {
var item = project.activeLayer.children[i];
item.rotate(3);
}
}
paper.view.draw();
i'm trying to learn some paper.js, and its onFrame event doesn't work with me :( In code below i create 30 random shapes on canvas, and trying to rotate each one of them by onFrame method, but nothing is happening, paths stand fixed.
var len = 30;
var array = new Array();
var rand;
var colors = ['#fbff00', '#99ff37', '#00eeff', '#374afe', '#ff005e'];
for(var i = 0; i < len; i++) {
rand = getRandom(0, 4);
switch (rand) {
case 0: // if 0, create circle
var path = new Path.Circle({
center: [getRandom(30, scrwidth - 30), getRandom(30, scrheight - 30)],
radius: 30
});
path.fillColor = colors[getRandom(0, 4)];
array.push(path);
break;
//and some others in the same way
}
}
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function onFrame(event) {
for (var i = 0; i < len; i++) {
var item = project.activeLayer.children[i];
item.rotate(3);
}
}
paper.view.draw();
Share
Improve this question
edited Nov 5, 2013 at 16:13
JustBeingHelpful
19k39 gold badges168 silver badges251 bronze badges
asked Jul 30, 2013 at 12:20
Alex KAlex K
1832 silver badges14 bronze badges
0
1 Answer
Reset to default 6I've done with that! Code should be ended that way:
view.onFrame = function(event) {
for (var i = 0; i < len; i++) {
var item = project.activeLayer.children[i];
item.rotate(3);
}
}
paper.view.draw();
i'm trying to learn some paper.js, and its onFrame event doesn't work with me :( In code below i create 30 random shapes on canvas, and trying to rotate each one of them by onFrame method, but nothing is happening, paths stand fixed.
var len = 30;
var array = new Array();
var rand;
var colors = ['#fbff00', '#99ff37', '#00eeff', '#374afe', '#ff005e'];
for(var i = 0; i < len; i++) {
rand = getRandom(0, 4);
switch (rand) {
case 0: // if 0, create circle
var path = new Path.Circle({
center: [getRandom(30, scrwidth - 30), getRandom(30, scrheight - 30)],
radius: 30
});
path.fillColor = colors[getRandom(0, 4)];
array.push(path);
break;
//and some others in the same way
}
}
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function onFrame(event) {
for (var i = 0; i < len; i++) {
var item = project.activeLayer.children[i];
item.rotate(3);
}
}
paper.view.draw();
i'm trying to learn some paper.js, and its onFrame event doesn't work with me :( In code below i create 30 random shapes on canvas, and trying to rotate each one of them by onFrame method, but nothing is happening, paths stand fixed.
var len = 30;
var array = new Array();
var rand;
var colors = ['#fbff00', '#99ff37', '#00eeff', '#374afe', '#ff005e'];
for(var i = 0; i < len; i++) {
rand = getRandom(0, 4);
switch (rand) {
case 0: // if 0, create circle
var path = new Path.Circle({
center: [getRandom(30, scrwidth - 30), getRandom(30, scrheight - 30)],
radius: 30
});
path.fillColor = colors[getRandom(0, 4)];
array.push(path);
break;
//and some others in the same way
}
}
function getRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function onFrame(event) {
for (var i = 0; i < len; i++) {
var item = project.activeLayer.children[i];
item.rotate(3);
}
}
paper.view.draw();
Share
Improve this question
edited Nov 5, 2013 at 16:13
JustBeingHelpful
19k39 gold badges168 silver badges251 bronze badges
asked Jul 30, 2013 at 12:20
Alex KAlex K
1832 silver badges14 bronze badges
0
1 Answer
Reset to default 6I've done with that! Code should be ended that way:
view.onFrame = function(event) {
for (var i = 0; i < len; i++) {
var item = project.activeLayer.children[i];
item.rotate(3);
}
}
paper.view.draw();
本文标签: javascriptpaperjs onFrame method doesn39t workStack Overflow
版权声明:本文标题:javascript - paper.js onFrame method doesn't work - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745510848a2153819.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论