Source for file Shadow.class.php
Documentation is available at Shadow.class.php
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
* @package linea21.externals
require_once dirname(__FILE__ ). "/../Graph.class.php";
define("SHADOW_LEFT_BOTTOM", 2);
define("SHADOW_RIGHT_TOP", 3);
define("SHADOW_RIGHT_BOTTOM", 4);
* Shadow on left and top sides
* Shadow on left and bottom sides
* Shadow on right and top sides
* Shadow on right and bottom sides
* @param int $position Shadow position
public function __construct($position) {
public function hide($hide = TRUE) {
$this->hide = (bool) $hide;
public function show($show = TRUE) {
$this->hide = (bool) !$show;
* @param bool $smooth Smooth the shadow (facultative argument)
public function setSize($size, $smooth = NULL) {
$this->size = (int) $size;
public function setColor(awColor $color) {
public function smooth($smooth) {
$this->smooth = (bool) $smooth;
* Get the space taken by the 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) {
$t2 = $p2->move($this->size + 1, $this->size + 1);
} else { // PHP 4 compatibility
$width = $t2->x - $t1->x;
$height = $t2->y - $t1->y;
$driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y);
$driver->filledRectangle(
new awPoint($width - 1, $height - 1)
$driver->filledRectangle(
$this->smoothPast($driver, $color, $width, $height);
$t1 = $p1->move(- $this->size, - $this->size);
} else { // PHP 4 compatibility
$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(
$driver->filledRectangle(
$this->smoothPast($driver, $color, $width, $height);
$t1 = $p1->move(0, - $this->size);
$t2 = $p2->move($this->size + 1, 0);
} else { // PHP 4 compatibility
$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(
$driver->filledRectangle(
$t1 = $p1->move(- $this->size, 0);
$t2 = $p2->move(0, $this->size + 1);
} else { // PHP 4 compatibility
$width = $t2->x - $t1->x;
$height = $t2->y - $t1->y;
$driver->setAbsPosition($t1->x + $driver->x, $t1->y + $driver->y);
$driver->filledRectangle(
$driver->filledRectangle(
private function smoothPast(awDriver $driver, awColor $color, $width, $height) {
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
private function smoothFuture(awDriver $driver, awColor $color, $width, $height) {
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
new awPoint($width - $this->size + $j, $height - $i - 1)
|