如何获取 paperJs 中的每个数组元素?
How to take each array elements in paperJs?
var path = new Path.Rectangle(new Point(50, 50), new Size(100, 50));
path.style = {
fillColor: 'white',
strokeColor: 'black'
};
var copy = {};
//Create a copy of the path and set its stroke color to red:
for (var i = 0; i < 100; i++) {
var copy[i] = path.clone();
console.log(copy[i]);
copy[i].strokeColor = 'red';
//Rotate the copy by 45 degrees:
copy[i].rotate(45);
}
您唯一需要做的就是将 copy
初始化为数组;
var copy = [];
var path = new Path.Rectangle(new Point(50, 50), new Size(100, 50));
path.style = {
fillColor: 'white',
strokeColor: 'black'
};
var copy = {};
//Create a copy of the path and set its stroke color to red:
for (var i = 0; i < 100; i++) {
var copy[i] = path.clone();
console.log(copy[i]);
copy[i].strokeColor = 'red';
//Rotate the copy by 45 degrees:
copy[i].rotate(45);
}
您唯一需要做的就是将 copy
初始化为数组;
var copy = [];