mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Clean up Chain example a bit.
This commit is contained in:
parent
d25ab05e25
commit
4f8ffde130
1 changed files with 8 additions and 4 deletions
|
@ -19,18 +19,22 @@
|
|||
for(var i = 0; i < size; i++)
|
||||
path.add(center + new Point(i * 100, 0));
|
||||
|
||||
onMouseMove = onMouseDrag = function(event) {
|
||||
function onMouseMove(event) {
|
||||
segments[0].point = event.point;
|
||||
for(var i = 0; i < size - 1; i++) {
|
||||
var nextSegment = segments[i + 1];
|
||||
var position = path.segments[i].point;
|
||||
var angle = (position - nextSegment.point).angle;
|
||||
var vector = -new Point({ angle: angle, length: 25 });
|
||||
nextSegment.point = position + vector;
|
||||
var vector = new Point({ angle: angle, length: 25 });
|
||||
nextSegment.point = position - vector;
|
||||
}
|
||||
path.smooth();
|
||||
}
|
||||
|
||||
|
||||
function onMouseDrag(event) {
|
||||
onMouseMove(event);
|
||||
}
|
||||
|
||||
function onMouseDown(event) {
|
||||
path.selected = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue