add offset() operation to OpenLayers.Pixel
git-svn-id: http://svn.openlayers.org/trunk/openlayers@444 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -66,6 +66,17 @@ OpenLayers.Pixel.prototype = {
|
||||
return new OpenLayers.Pixel(this.x + x, this.y + y);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @return a new Pixel with this pixel's x&y augmented by the
|
||||
* x&y values of the pixel passed in.
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
offset:function(px) {
|
||||
return this.add(px.x, px.y);
|
||||
},
|
||||
|
||||
/** @final @type str */
|
||||
CLASS_NAME: "OpenLayers.Pixel"
|
||||
};
|
||||
|
||||
@@ -61,6 +61,21 @@
|
||||
t.eq( pixel.y, 26, "pixel.y is set correctly");
|
||||
}
|
||||
|
||||
function test_08_Pixel_offset(t) {
|
||||
t.plan( 4 );
|
||||
|
||||
var oldPixel = new OpenLayers.Pixel(5,6);
|
||||
var offset = new OpenLayers.Pixel(10,20);
|
||||
|
||||
pixel = oldPixel.offset(offset);
|
||||
|
||||
t.eq( oldPixel.x, 5, "oldPixel.x not modified by offset operation");
|
||||
t.eq( oldPixel.y, 6, "oldPixel.y not modified by offset operation");
|
||||
|
||||
t.eq( pixel.x, 15, "pixel.x is set correctly");
|
||||
t.eq( pixel.y, 26, "pixel.y is set correctly");
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user