Examples TOCexamples

Circle Plain

$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.

Default circle (size:50x50) filled in natural way.

There are 10 cells with default colors :

Percent text info is right aligned on a #EEEEEE background color area of 50 pixels width, at right side of circle.

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

[Top]

 Render options

background-color = #EEEEEE
HTML_Progress_UI::setStringAttributes()
background-color = #EEEEEE
spacing          = 0
width            = 50
height           = 50
HTML_Progress_UI::setCellAttributes()

[Top]

 Output

Screenshots

[Top]

 PHP source syntax highlight

  1. <?php
  2. /**
  3.  * plain Circle Progress example.
  4.  *
  5.  * @version    $Id: circleplain.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->setStringAttributes('background-color=#eeeeee');
  19. $ui->setCellAttributes('width=50 height=50 spacing=0 background-color=#eeeeee');
  20.  
  21. if (file_exists('../temp/c0.png')) {
  22.     // uses cached files rather than create it again and again
  23.     foreach (range(0,10) as $index) {
  24.         $ui->setCellAttributes(array('background-image' => '../temp/c'.$index.'.png'),$index);
  25.     }
  26. } else {
  27.     // creates circle segments pictures only once
  28.     $ui->drawCircleSegments('../temp', 'c%s.png');
  29. }
  30. ?>
  31. <html>
  32. <head>
  33. <title>Basic Circle ProgressBar example</title>
  34. <style type="text/css">
  35. <!--
  36. <?php echo $bar->getStyle(); ?>
  37.  
  38. body {
  39.     background-color: #EEEEEE;
  40.     color: #000000;
  41.     font-family: Verdana, Arial;
  42. }
  43.  
  44. a:visited, a:active, a:link {
  45.     color: navy;
  46. }
  47. // -->
  48. </style>
  49. <script type="text/javascript">
  50. <!--
  51. <?php echo $ui->getScript(); ?>
  52. //-->
  53. </script>
  54. </head>
  55. <body>
  56.  
  57. <?php
  58. echo $bar->toHtml();
  59. $bar->run();
  60. ?>
  61.  
  62. </body>
  63. </html>

[Top]