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
function awShadow($position) {
function hide($hide = TRUE) {
$this->hide = (bool) $hide;
function show($show = TRUE) {
$this->hide = (bool) !$show;
* @param bool $smooth Smooth the shadow (facultative argument)
function setSize($size, $smooth = NULL) {
$this->size = (int) $size;
$this->position = (int) $position;
$this->smooth = (bool) $smooth;
* Get the space taken by the shadow
* @param $p1 Top-left point
* @param $p2 Right-bottom point
* @param int Drawing mode
function draw($driver, $p1, $p2, $mode) {
$color = (is_a($this->color, 'awColor')) ? $this->color : new awColor(125, 125, 125);
switch($this->position) {
$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 - $this->size, $this->size),
new awPoint($width - 1, $height - 1)
$driver->filledRectangle(
new awPoint($this->size, $height - $this->size),
new awPoint($width - $this->size - 1, $height - 1)
$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(
new awPoint($this->size - 1, $height - $this->size - 1)
$driver->filledRectangle(
new awPoint($width - $this->size - 1, $this->size - 1)
$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(
new awPoint($width - $this->size, 0),
new awPoint($width - 1, $height - $this->size - 1)
$driver->filledRectangle(
new awPoint($width - $this->size - 1, $this->size - 1)
$this->smoothFuture($driver, $color, $width, $height);
$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(
new awPoint($this->size - 1, $height - 1)
$driver->filledRectangle(
new awPoint($this->size, $height - $this->size),
new awPoint($width - $this->size - 1, $height - 1)
$this->smoothFuture($driver, $color, $width, $height);
function smoothPast($driver, $color, $width, $height) {
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
new awPoint($i, $j + $height - $this->size)
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
new awPoint($width - $this->size + $j, $i)
function smoothFuture($driver, $color, $width, $height) {
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
new awPoint($i, $this->size - $j - 1)
for($i = 0; $i < $this->size; $i++ ) {
for($j = 0; $j <= $i; $j++ ) {
new awPoint($width - $this->size + $j, $height - $i - 1)
|