#807 - give geometries a resize method - examples and tests for demonstration

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3631 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-07-06 20:32:22 +00:00
parent 0d596fbb03
commit c2fcb22d98
5 changed files with 141 additions and 0 deletions

View File

@@ -260,6 +260,24 @@ OpenLayers.Geometry.Collection.prototype =
}
},
/**
* APIMethod: resize
* Resize a geometry relative to some origin. Use this method to apply
* a uniform scaling to a geometry.
*
* Parameters:
* scale - {Float} Factor by which to scale the geometry. A scale of 2
* doubles the size of the geometry in each dimension
* (lines, for example, will be twice as long, and polygons
* will have four times the area).
* origin - {OpenLayers.Geometry.Point} Point of origin for resizing
*/
resize: function(scale, origin) {
for(var i=0; i<this.components.length; ++i) {
this.components[i].resize(scale, origin);
}
},
/**
* APIMethod: equals
* Tests for equivalent geometries

View File

@@ -148,6 +148,23 @@ OpenLayers.Geometry.Point.prototype =
this.y = origin.y + (radius * Math.sin(theta));
},
/**
* APIMethod: resize
* Resize a point relative to some origin. For points, this has the effect
* of scaling a vector (from the origin to the point). This method is
* more useful on geometry collection subclasses.
*
* Parameters:
* scale - {Float} Ratio of the new distance from the origin to the old
* distance from the origin. A scale of 2 doubles the
* distance between the point and origin.
* origin - {OpenLayers.Geometry.Point} Point of origin for resizing
*/
resize: function(scale, origin) {
this.x = origin.x + (scale * (this.x - origin.x));
this.y = origin.y + (scale * (this.y - origin.y));
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Geometry.Point"
});