summaryrefslogtreecommitdiffstats
path: root/src/point.js
diff options
context:
space:
mode:
authorRémi Tétreault <tetreault.remi@gmail.com>2016-12-20 21:33:18 -0500
committerRémi Tétreault <tetreault.remi@gmail.com>2016-12-20 21:33:18 -0500
commit80acdb3d77aa228071a54de806a614ebf50fe49e (patch)
treef68ab5f3d6a40305fafe52f927129846be76ef2a /src/point.js
parent1c4e6f093f197ca51715df2d44b4175c7c29204c (diff)
downloadsvg.js-80acdb3d77aa228071a54de806a614ebf50fe49e.tar.gz
svg.js-80acdb3d77aa228071a54de806a614ebf50fe49e.zip
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.
Diffstat (limited to 'src/point.js')
-rw-r--r--src/point.js35
1 files changed, 2 insertions, 33 deletions
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()
- }
+
}
})