Login   Register  
PHP Classes
elePHPant
Icontem

File: shadowgd_demo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrew Wilson  >  shadowgd  >  shadowgd_demo.php  >  Download  
File: shadowgd_demo.php
Role: Example script
Content type: text/plain
Description: Class demo
Class: shadowgd
Draw GD graphics shapes with drop shadows
Author: By
Last change:
Date: 11 years ago
Size: 3,072 bytes
 

Contents

Class file image Download
<?php
require "shadowgdclass.php";

Header("Content-type: image/jpeg");
$demo_width 600;
$demo_height 500;
$image ImageCreate($demo_width$demo_height);
// set up colors
$lt_gray ImageColorAllocate($image204204204);
$black ImageColorAllocate($image,0,0,0);
$white ImageColorAllocate($image255255255);
$lt_blue ImageColorAllocate($image,51153204);
$drk_blue ImageColorAllocate($image,00153);
$blue_bkgd ImageColorAllocate($image153255255);
$blue ImageColorAllocate($image,0,0,255);
$green ImageColorAllocate($image,02550);
$red ImageColorAllocate($image25500);
// draw background
ImageFilledRectangle($image1010$demo_width 10$demo_height 2$white);
ImageFilledRectangle($image10$demo_height /2$demo_width 10$demo_height 10$blue_bkgd);
ImageSetThickness($image5);
ImageRectangle($image1010$demo_width 10$demo_height 10$black);
ImageSetThickness($image1);
// draw title
$title "ShadowGD Demo";
$char_width ImageFontWidth(5);
$title_width strlen($title) * $char_width;
$title_x 300 - ($title_width 2);
ImageString($image5$title_x20$title$black);

$grfx = new shadowgd($image);
// bar chart
// draw axes
ImageSetThickness($image4);
ImageLine($image438043220$black);
ImageLine($image43220270220$black);
ImageSetThickness($image1);
// first bar
$shape_coords = array(45100170130);
$grfx->DrawShadowRectangle($shape_coords$green);
// second bar
$shape_coords = array(45140200170);
$grfx->DrawShadowRectangle($shape_coords$drk_blue);
// third bar
$shape_coords = array(45180250210);
$grfx->DrawShadowRectangle($shape_coords$red);

// pie chart
$base_x 425;
$base_y 160;
ImageFilledArc($image$base_x$base_y100100040$redIMG_ARC_PIE);
ImageFilledArc($image$base_x$base_y10010040200$blueIMG_ARC_PIE);
// find position of offset wedge
$wedge_angle 280;
$arc_center[0] = $base_x - (15 sin($wedge_angle));
$arc_center[1] = $base_y + (15 cos($wedge_angle));
$grfx->DrawShadowArc($arc_center100100200360$greenfalse);

// changing shadow params demo
// blue shadow, size 6, direction 0
$base_x 150;
$base_y 360;
$shape_coords = array($base_x$base_y);
$grfx->SetShadow(60$lt_blue$drk_blue);
$grfx->DrawShadowEllipse($shape_coords6040$green);
// blue shadow, size 4, direction 1, no outline
$base_x 380;
$base_y 330;
$shape_coords = array($base_x$base_y$base_x 40$base_y 40$base_x 40$base_y 70$base_x$base_y 70);
$grfx->SetShadow(41$lt_blue$drk_blue);
$grfx->DrawShadowPolygon($shape_coords$redfalse);
// blue shadow, size 4, direction 5
$base_x 450;
$base_y 330;
$shape_coords = array($base_x$base_y$base_x 40$base_y 40$base_x 40$base_y 70$base_x$base_y 70);
$grfx->SetShadow(45$lt_blue$drk_blue);
$grfx->DrawShadowPolygon($shape_coords$blue);

ImageJPEG($image);
ImageDestroy($image);

?>