public function setX($x) { if ($x >= 0) { // Absolute value. $this->x = $x; } else { // Negative, so relative to right edge of the page. $this->x = $this->w + $x; } }