Clean up Chain example a bit.

This commit is contained in:
Jürg Lehni 2011-04-21 12:36:46 +01:00
parent d25ab05e25
commit 4f8ffde130

View file

@ -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;
}