mirror of
https://github.com/Leaflet/Leaflet.git
synced 2026-02-01 17:27:23 +00:00
new Point methods
This commit is contained in:
parent
64a40b3880
commit
a2d2fed2db
@ -40,4 +40,6 @@ describe("Point", function() {
|
||||
expect(new L.Point(50, 30).multiplyBy(2)).toEqual(new L.Point(100, 60));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#distanceTo', noSpecs);
|
||||
});
|
||||
@ -22,5 +22,19 @@ L.Point.prototype = {
|
||||
|
||||
multiplyBy: function(num) {
|
||||
return new L.Point(this.x * num, this.y * num);
|
||||
},
|
||||
|
||||
distanceTo: function(point) {
|
||||
var x = point.x - this.x,
|
||||
y = point.y - this.y;
|
||||
return Math.sqrt(x*x + y*y);
|
||||
},
|
||||
|
||||
round: function() {
|
||||
return new L.Point(Math.round(this.x), Math.round(this.y));
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
return 'Point(' + this.x + ',' + this.y + ')';
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user