From 31e2c37e0d2dec138aacbb350fc2e1fc2e270a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 8 Dec 2013 11:14:36 +0100 Subject: [PATCH] Clean up Tadpoles code further. --- examples/Paperjs.org/Tadpoles.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/Paperjs.org/Tadpoles.html b/examples/Paperjs.org/Tadpoles.html index b5c56900..a389d112 100644 --- a/examples/Paperjs.org/Tadpoles.html +++ b/examples/Paperjs.org/Tadpoles.html @@ -43,22 +43,22 @@ shortSegments = this.shortPath.segments; var speed = this.vector.length; var pieceLength = 5 + speed * 0.3; - var point = this.position.clone(); + var point = this.position; segments[0].point = shortSegments[0].point = point; // Chain goes the other way than the movement var lastVector = -this.vector; for (var i = 1; i < this.amount; i++) { var vector = segments[i].point - point; - var sideways = lastVector.rotate(90); this.count += speed * 15; - sideways.length = Math.sin((this.count + i * 3) * 0.003); - lastVector.length = pieceLength; - point += lastVector + sideways; + var wave = Math.sin((this.count + i * 3) * 0.003); + var sway = lastVector.rotate(90).normalize(wave); + point += lastVector.normalize(pieceLength) + sway; segments[i].point = point; if (i < 3) shortSegments[i].point = point; lastVector = vector; } + // this.path.smooth(); }, createItems: function() {