Examples TOCexamples

Circle Back

$Date: 2005/07/25 11:19:41 $

 Table of contents

Introduction

This example requires :


This example will display a plain circle 360 degree as new shape of progress meter.

This example will run a circle (size:100x100) filled in reverse way.

There are 10 cells with :

Percent text info is right aligned on a 100 pixels width area, at right side of circle.

A cache system is used on lines 29 thru 37, to avoid built pictures a second times.

[Top]

 Render options

Here are options to build this progress bar string (percent text info):
font-size = 20
width     = 100
HTML_Progress_UI::setStringAttributes()
Here are options to build the progress bar cells :
width          = 100
height         = 100
spacing        = 0
inactive-color = navy
active-color   = red
HTML_Progress_UI::setCellAttributes()

[Top]

 Output

Screenshots

[Top]

 PHP source syntax highlight

  1. <?php
  2. /**
  3.  * Custom Circle Reverse Progress example.
  4.  *
  5.  * @version    $Id: circleback.php,v 1.2 2005/07/25 11:19:41 farell Exp $
  6.  * @author     Laurent Laville <pear@laurent-laville.org>
  7.  * @package    HTML_Progress
  8.  * @subpackage Examples
  9.  */
  10.  
  11. require_once 'HTML/Progress.php';
  12.  
  13. $bar = new HTML_Progress(HTML_PROGRESS_CIRCLE);
  14. $bar->setAnimSpeed(100);
  15. $bar->setIncrement(10);
  16.  
  17. $ui =& $bar->getUI();
  18. $ui->setfillway('reverse');
  19. $ui->setStringAttributes('font-size=20 width=100');
  20. $ui->setCellAttributes(array(
  21.     'width' => 100,
  22.     'height' => 100,
  23.     'spacing' => 0,
  24.     'inactive-color' => 'navy',
  25.     'active-color' => 'red'
  26.     )
  27. );
  28.  
  29. if (file_exists('../temp/cb0.png')) {
  30.     // uses cached files rather than create it again and again
  31.     foreach (range(0,10) as $index) {
  32.         $ui->setCellAttributes(array('background-image' => '../temp/cb'.$index.'.png'),$index);
  33.     }
  34. } else {
  35.     // creates circle segments pictures only once
  36.     $ui->drawCircleSegments('../temp', 'cb%s.png');
  37. }
  38. ?>
  39. <html>
  40. <head>
  41. <title>Custom Circle Reverse ProgressBar example</title>
  42. <style type="text/css">
  43. <!--
  44. <?php echo $bar->getStyle(); ?>
  45.  
  46. body {
  47.     background-color: #FFFFFF;
  48.     color: #000000;
  49.     font-family: Verdana, Arial;
  50. }
  51.  
  52. a:visited, a:active, a:link {
  53.     color: navy;
  54. }
  55. // -->
  56. </style>
  57. <script type="text/javascript">
  58. <!--
  59. <?php echo $ui->getScript(); ?>
  60. //-->
  61. </script>
  62. </head>
  63. <body>
  64.  
  65. <?php
  66. echo $bar->toHtml();
  67. $bar->run();
  68. ?>
  69.  
  70. </body>
  71. </html>

[Top]