Skip to content

Instantly share code, notes, and snippets.

@mmorton
Created July 18, 2012 08:31
Show Gist options
  • Save mmorton/3135051 to your computer and use it in GitHub Desktop.
Save mmorton/3135051 to your computer and use it in GitHub Desktop.
var Point = function(x, y) {
if (arguments.length == 1)
{
this.x = (x >> 12) & 0xFFF;
this.y = (x) & 0xFFF;
}
else
{
this.x = x;
this.y = y;
}
};
Point.prototype.valueOf = function() {
return ((this.x & 0xFFF) << 12) + ((this.y & 0xFFF));
};
Point.prototype.toString = function() {
return '{' + this.x + ',' + this.y + '}';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment