function Rectangle(){this.type= RECTANGLE_TYPE
this.coord1= new Coord(0,0);this.size= new Size(50,50);if(arguments[1].type==SIZE_TYPE){this.coord1= arguments[0].getCopy();this.size= arguments[1].getCopy()}else{this.coord1= arguments[0].getCopy();this.coord2= arguments[1].getCopy();this.size= new Size(this.coord1, this.coord2)}
if(!this.coord2)this.coord2= this.coord1.getCopy().add(this.size);this.setCoord1= setRectangleCoord1;this.setCoord2= setRectangleCoord2;this.arrangeDimensions= arrangeDimensions;this.arrangeDimensions()
return this}
function setRectangleCoord1(x,y){this.coord1.set(x,y);this.coord2.add(this.size);this.arrangeDimensions()}
function setRectangleCoord2(x,y){this.coord2.set(x,y);this.size= new Size(this.coord1, this.coord2);this.arrangeDimensions()}
function arrangeDimensions(){this.top= this.coord1.y;this.bottom= this.coord2.y;this.left= this.coord1.x;this.right= this.coord2.x}
