Created
March 25, 2010 14:58
-
-
Save rhyolight/343637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PositionedRectangle = function(w,h,xIn,yIn) { | |
var x = xIn, | |
y = yIn, | |
rect = new ORectangle(w,h), | |
me = { | |
getX: function() { return x; }, | |
setX: function(xIn) { this.x = xIn; }, | |
getY: function() { return y; }, | |
setY: function(yIn) { this.y = yIn; }, | |
distanceFrom: function(otherRect) { | |
return Math.sqrt( | |
Math.pow(this.getX() - otherRect.getX(), 2) | |
+ Math.pow(this.getY() - otherRect.getY(), 2) | |
); | |
}, | |
toString: function() { | |
return rect.toString() + ' at ' + this.getX() + ',' + this.getY(); | |
} | |
}; | |
return mixin(rect, me); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment