/** * Draw shadow * * @param awDriver $driver * @param awPoint $p1 Top-left point * @param awPoint $p2 Right-bottom point * @param int Drawing mode */ public function draw(awDriver $driver, awPoint $p1, awPoint $p2, $mode) { if ($this->hide) { return; } if ($this->size <= 0) { return; } $driver = clone $driver; $color = $this->color instanceof awColor ? $this->color : new awColor(125, 125, 125); switch ($this->position) { case awShadow::RIGHT_BOTTOM: if ($mode === awShadow::OUT) { $t1 = $p1->move(0, 0); $t2 = $p2->move($this->size + 1, $this->size + 1); } else { // PHP 4 compatibility $t1 = $p1->move(0, 0); $t2 = $p2->move(0, 0); } $width = $t2->x - $t1->x; $height = $t2->y - $t1->y; $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); $driver->filledRectangle($color, new awLine(new awPoint($width - $this->size, $this->size), new awPoint($width - 1, $height - 1))); $driver->filledRectangle($color, new awLine(new awPoint($this->size, $height - $this->size), new awPoint($width - $this->size - 1, $height - 1))); $this->smoothPast($driver, $color, $width, $height); break; case awShadow::LEFT_TOP: if ($mode === awShadow::OUT) { $t1 = $p1->move(-$this->size, -$this->size); $t2 = $p2->move(0, 0); } else { // PHP 4 compatibility $t1 = $p1->move(0, 0); $t2 = $p2->move(0, 0); } $width = $t2->x - $t1->x; $height = $t2->y - $t1->y; $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); $height = max($height + 1, $this->size); $driver->filledRectangle($color, new awLine(new awPoint(0, 0), new awPoint($this->size - 1, $height - $this->size - 1))); $driver->filledRectangle($color, new awLine(new awPoint($this->size, 0), new awPoint($width - $this->size - 1, $this->size - 1))); $this->smoothPast($driver, $color, $width, $height); break; case awShadow::RIGHT_TOP: if ($mode === awShadow::OUT) { $t1 = $p1->move(0, -$this->size); $t2 = $p2->move($this->size + 1, 0); } else { // PHP 4 compatibility $t1 = $p1->move(0, 0); $t2 = $p2->move(0, 0); } $width = $t2->x - $t1->x; $height = $t2->y - $t1->y; $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); $height = max($height + 1, $this->size); $driver->filledRectangle($color, new awLine(new awPoint($width - $this->size, 0), new awPoint($width - 1, $height - $this->size - 1))); $driver->filledRectangle($color, new awLine(new awPoint($this->size, 0), new awPoint($width - $this->size - 1, $this->size - 1))); $this->smoothFuture($driver, $color, $width, $height); break; case awShadow::LEFT_BOTTOM: if ($mode === awShadow::OUT) { $t1 = $p1->move(-$this->size, 0); $t2 = $p2->move(0, $this->size + 1); } else { // PHP 4 compatibility $t1 = $p1->move(0, 0); $t2 = $p2->move(0, 0); } $width = $t2->x - $t1->x; $height = $t2->y - $t1->y; $driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y); $driver->filledRectangle($color, new awLine(new awPoint(0, $this->size), new awPoint($this->size - 1, $height - 1))); $driver->filledRectangle($color, new awLine(new awPoint($this->size, $height - $this->size), new awPoint($width - $this->size - 1, $height - 1))); $this->smoothFuture($driver, $color, $width, $height); break; } }
/** * Draw a pixel * * @param awColor $color Pixel color * @param awPoint $p */ public function point(awColor $color, awPoint $p) { if ($p->isHidden() === FALSE) { list($red, $green, $blue, $alpha) = $this->getColor($color); $point = new SWFShape(); $point->setLine(1, $red, $green, $blue, $alpha); $point->movePenTo($this->x + round($p->x), $this->y + round($p->y)); $point->drawLine(0.5, 0.5); $point->movePen(-0.5, 0); $point->drawLine(0.5, -0.5); $this->movie->add($point); } }
protected function rectangleLinearGradient(awLinearGradient $gradient, awPoint $p1, awPoint $p2) { list($x1, $y1) = $p1->getLocation(); list($x2, $y2) = $p2->getLocation(); if ($y1 - $y2 > 0) { if ($gradient->angle === 0) { $this->init($gradient, $y1 - $y2); for ($i = $y2; $i <= $y1; $i++) { $color = $this->color($i - $y2); $p1 = new awPoint($x1, $i); $p2 = new awPoint($x2, $i); $this->driver->filledRectangle($color, new awLine($p1, $p2)); unset($color); } } elseif ($gradient->angle === 90) { $this->init($gradient, $x2 - $x1); for ($i = $x1; $i <= $x2; $i++) { $color = $this->color($i - $x1); $p1 = new awPoint($i, $y2); $p2 = new awPoint($i, $y1); $this->driver->filledRectangle($color, new awLine($p1, $p2)); unset($color); } } } }
protected function drawImage(awPoint $point) { if ($this->image instanceof awImage) { $width = $this->image->width; $height = $this->image->height; list($x, $y) = $point->getLocation(); $x1 = (int) ($x - $width / 2); $x2 = $x1 + $width; $y1 = (int) ($y - $width / 2); $y2 = $y1 + $height; $this->border->rectangle($this->driver, new awPoint($x1 - 1, $y1 - 1), new awPoint($x2 + 1, $y2 + 1)); $this->driver->copyImage($this->image, new awPoint($x1, $y1), new awPoint($x2, $y2)); } }