left = $left; $this->top = $top; $this->width = $width; $this->height = $height; } function __get($name) { switch ($name) { case 'right': return $this->left + $this->width; case 'bottom': return $this->top + $this->height; } } function __set($name, $value) { switch ($name) { case 'right': $this->width = $value - $this->left; case 'bottom': $this->height = $value - $this->top; } } /** * Смещает прямоугольник на заданное положение */ function addPoint(Point $point) { $result = clone $this; $result->left += $point->left; $result->top += $point->top; return $result; } /** * Координаты точки при выравнивании прямоугольника относительно текущего */ function alignment(Rectangle $base) { return new Point((($base->left + $base->right) - ($this->left + $this->right)) / 2, $base->bottom - $this->height); } } ?>