function Coord(x, y) { this.x = (!x)?0:x; this.y = (!y)?0:y; this.toString = objToString; this.equals = equalsCoord; } function objToString() { var ret = "{"; for(p in this ) { if (typeof this[p] == "function" || typeof this[p] == "object") continue; if(ret.length > 1) ret += ","; ret += p + ":" + this[p]; } return ret + "}"; } function Canvas(x, y, width, height) { this.width = (!width)?0:width; this.height = (!height)?0:height; this.Coord = Coord; this.Coord(x, y); this.equalsCoord = this.equals; this.equals = equalsCanvas; } function equalsCoord(c) { return (this.x == c.x && this.y == c.y); } function equalsCanvas(c) { return ( this.equalsCoord == c.equalsCoord && this.width == c.width && this.height == c.height); }