mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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++)
|
for(var i = 0; i < size; i++)
|
||||||
path.add(center + new Point(i * 100, 0));
|
path.add(center + new Point(i * 100, 0));
|
||||||
|
|
||||||
onMouseMove = onMouseDrag = function(event) {
|
function onMouseMove(event) {
|
||||||
segments[0].point = event.point;
|
segments[0].point = event.point;
|
||||||
for(var i = 0; i < size - 1; i++) {
|
for(var i = 0; i < size - 1; i++) {
|
||||||
var nextSegment = segments[i + 1];
|
var nextSegment = segments[i + 1];
|
||||||
var position = path.segments[i].point;
|
var position = path.segments[i].point;
|
||||||
var angle = (position - nextSegment.point).angle;
|
var angle = (position - nextSegment.point).angle;
|
||||||
var vector = -new Point({ angle: angle, length: 25 });
|
var vector = new Point({ angle: angle, length: 25 });
|
||||||
nextSegment.point = position + vector;
|
nextSegment.point = position - vector;
|
||||||
}
|
}
|
||||||
path.smooth();
|
path.smooth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onMouseDrag(event) {
|
||||||
|
onMouseMove(event);
|
||||||
|
}
|
||||||
|
|
||||||
function onMouseDown(event) {
|
function onMouseDown(event) {
|
||||||
path.selected = true;
|
path.selected = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue