mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Improve Space examples.
This commit is contained in:
parent
3263b91708
commit
7c5d377133
2 changed files with 10 additions and 8 deletions
|
@ -10,11 +10,12 @@
|
|||
var count = 150;
|
||||
|
||||
// Create a symbol, which we will use to place instances of later:
|
||||
var path = new Path.Circle(new Point(0, 0), 5);
|
||||
path.style = {
|
||||
var path = new Path.Circle({
|
||||
center: new Point(0, 0),
|
||||
radius: 5,
|
||||
fillColor: 'white',
|
||||
strokeColor: 'black'
|
||||
};
|
||||
});
|
||||
|
||||
var symbol = new Symbol(path);
|
||||
|
||||
|
@ -23,11 +24,11 @@
|
|||
// The center position is a random point in the view:
|
||||
var center = Point.random() * view.size;
|
||||
var placed = symbol.place(center);
|
||||
placed.scale(i / count);
|
||||
placed.data = {};
|
||||
var scale = (i + 1) / count;
|
||||
placed.scale(scale);
|
||||
placed.data.vector = new Point({
|
||||
angle: Math.random() * 360,
|
||||
length : (i / count) * Math.random() / 5
|
||||
length : scale * Math.random() / 5
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
for (var i = 0; i < count; i++) {
|
||||
// The center position is a random point in the view:
|
||||
var center = Point.random() * view.size;
|
||||
var path = new Shape.Circle(center, 5 * (i / count));
|
||||
var scale = (i + 1) / count;
|
||||
var path = new Shape.Circle(center, 5 * scale);
|
||||
path.data.vector = new Point({
|
||||
angle: Math.random() * 360,
|
||||
length : (i / count) * Math.random() / 5
|
||||
length : scale * Math.random() / 5
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue