Sha256: f4a5882504bd79c57f9a76dc9553d8d5aca62a2f136f24df9795b541184ffbc8

Contents?: true

Size: 801 Bytes

Versions: 10

Compression:

Stored size: 801 Bytes

Contents

/*
 * L.Transformation is an utility class to perform simple point transformations through a 2d-matrix.
 */

L.Transformation = function (a, b, c, d) {
	this._a = a;
	this._b = b;
	this._c = c;
	this._d = d;
};

L.Transformation.prototype = {
	transform: function (point, scale) { // (Point, Number) -> Point
		return this._transform(point.clone(), scale);
	},

	// destructive transform (faster)
	_transform: function (point, scale) {
		scale = scale || 1;
		point.x = scale * (this._a * point.x + this._b);
		point.y = scale * (this._c * point.y + this._d);
		return point;
	},

	untransform: function (point, scale) {
		scale = scale || 1;
		return new L.Point(
		        (point.x / scale - this._b) / this._a,
		        (point.y / scale - this._d) / this._c);
	}
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
leaflet-js-0.7.9 vendor/assets/Leaflet/src/geometry/Transformation.js
leaflet-js-0.7.8 vendor/assets/Leaflet/src/geometry/Transformation.js
leaflet-js-0.7.7 vendor/assets/Leaflet/src/geometry/Transformation.js
leaflet-js-0.8.dev2 lib/leaflet/src/geometry/Transformation.js
leaflet-js-0.7.0.4 lib/leaflet/src/geometry/Transformation.js
leaflet-js-0.7.0.3 lib/leaflet/src/geometry/Transformation.js
leaflet-js-0.7.0.2 lib/leaflet/src/geometry/Transformation.js
leaflet-js-0.7.0.1 lib/leaflet/src/geometry/Transformation.js
leaflet-js-0.7.0 lib/leaflet/src/geometry/Transformation.js
leaflet-js-0.6.beta4 lib/leaflet/src/geometry/Transformation.js