From 80acdb3d77aa228071a54de806a614ebf50fe49e Mon Sep 17 00:00:00 2001 From: Rémi Tétreault Date: Tue, 20 Dec 2016 21:33:18 -0500 Subject: Implement a more basic morph method for SVG.PathArray The method expect the paths to use the exact same commands. It will not attempt to modify them if they do not. Any more complex algorithm shall be provided as a plugin instead in order to keep the size of the library down. --- src/point.js | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'src/point.js') diff --git a/src/point.js b/src/point.js index 226f4e0..3a54d43 100644 --- a/src/point.js +++ b/src/point.js @@ -10,7 +10,7 @@ SVG.Point = SVG.invent({ {x:x.x, y:x.y} : x != null ? {x:x, y:(y != null ? y : x)} : base // If y has no value, then x is used has its value - // This allow element-wise operations to be passed a single number + // merge source this.x = source.x this.y = source.y @@ -57,38 +57,7 @@ SVG.Point = SVG.invent({ , transform: function(matrix) { return new SVG.Point(this.native().matrixTransform(matrix.native())) } - // return an array of the x and y coordinates - , toArray: function() { - return [this.x, this.y] - } - // perform an element-wise addition with the passed point or number - , plus: function(x, y) { - var point = new SVG.Point(x, y) - return new SVG.Point(this.x + point.x, this.y + point.y) - } - // perform an element-wise subtraction with the passed point or number - , minus: function(x, y) { - var point = new SVG.Point(x, y) - return new SVG.Point(this.x - point.x, this.y - point.y) - } - // perform an element-wise multiplication with the passed point or number - , times: function(x, y) { - var point = new SVG.Point(x, y) - return new SVG.Point(this.x * point.x, this.y * point.y) - } - // perform an element-wise division with the passed point or number - , divide: function(x, y) { - var point = new SVG.Point(x, y) - return new SVG.Point(this.x / point.x, this.y / point.y) - } - // calculate the Euclidean norm - , norm: function() { - return Math.sqrt(this.x*this.x + this.y*this.y) - } - // calculate the distance to the passed point - , distance: function(x, y) { - return this.minus(x, y).norm() - } + } }) -- cgit v1.2.3