mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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;
|
var count = 150;
|
||||||
|
|
||||||
// Create a symbol, which we will use to place instances of later:
|
// Create a symbol, which we will use to place instances of later:
|
||||||
var path = new Path.Circle(new Point(0, 0), 5);
|
var path = new Path.Circle({
|
||||||
path.style = {
|
center: new Point(0, 0),
|
||||||
|
radius: 5,
|
||||||
fillColor: 'white',
|
fillColor: 'white',
|
||||||
strokeColor: 'black'
|
strokeColor: 'black'
|
||||||
};
|
});
|
||||||
|
|
||||||
var symbol = new Symbol(path);
|
var symbol = new Symbol(path);
|
||||||
|
|
||||||
|
@ -23,11 +24,11 @@
|
||||||
// The center position is a random point in the view:
|
// The center position is a random point in the view:
|
||||||
var center = Point.random() * view.size;
|
var center = Point.random() * view.size;
|
||||||
var placed = symbol.place(center);
|
var placed = symbol.place(center);
|
||||||
placed.scale(i / count);
|
var scale = (i + 1) / count;
|
||||||
placed.data = {};
|
placed.scale(scale);
|
||||||
placed.data.vector = new Point({
|
placed.data.vector = new Point({
|
||||||
angle: Math.random() * 360,
|
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++) {
|
for (var i = 0; i < count; i++) {
|
||||||
// The center position is a random point in the view:
|
// The center position is a random point in the view:
|
||||||
var center = Point.random() * view.size;
|
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({
|
path.data.vector = new Point({
|
||||||
angle: Math.random() * 360,
|
angle: Math.random() * 360,
|
||||||
length : (i / count) * Math.random() / 5
|
length : scale * Math.random() / 5
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue