1<?php 2 3class Rectangle { 4 var $ur; 5 var $ll; 6 7 function Rectangle($ll, $ur) { 8 $this->ll = $ll; 9 $this->ur = $ur; 10 } 11 12 function getWidth() { 13 return $this->ur->x - $this->ll->x; 14 } 15 16 function getHeight() { 17 return $this->ur->y - $this->ll->y; 18 } 19 20 function normalize() { 21 if ($this->ur->x < $this->ll->x) { 22 $x = $this->ur->x; 23 $this->ur->x = $this->ll->x; 24 $this->ll->x = $x; 25 }; 26 27 if ($this->ur->y < $this->ll->y) { 28 $y = $this->ur->y; 29 $this->ur->y = $this->ll->y; 30 $this->ll->y = $y; 31 }; 32 } 33} 34 35?>