Square

Overview

This example will run four progress meter that display a square 3x3
Starting first on top left corner, then on top right, then on bottom right, and finally on bottom left.

Screenshot

sample screenshot

Demonstration

Give it a try

Dependencies

This example requires mandatory resources :

And also but optional :

Explains step by step

The progress meter wait 200ms (line 16) between each step of 10% (line 17).

There are 8 cells 20x20 organized into polygonal shape (lines 18-19), a basic square 3x3 (lines 21,46) :

Property Value Default
active-color   #006600
inactive-color   #CCCCCC
width 20 15
height 20 20
spacing   2
See also :

Square coordinates are changed to begin :

And the progress percent text info is center aligned on top side (line 20):

Property Value Default
left   5
top   5
width   50
height 20 0
align center right
valign top right
background-color   
font-size  11
font-family  Verdana, Tahoma, Arial
font-weight  normal
color  #000000
class  progressPercentLabel%s
See also :

Source Code

  1. <?php
  2. /**
  3. * Basic squares progress meter started in each corners.
  4. * A simple rotate function (for-loop) is applied
  5. * on reference coordinates to give new ones.
  6. *
  7. * @version    $Id: square.php,v 1.4 2006/05/24 08:41:13 farell Exp $
  8. * @author     Laurent Laville <pear@laurent-laville.org>
  9. * @package    HTML_Progress2
  10. * @subpackage Examples
  11. * @access     public
  12. */
  13. require_once 'HTML/Progress2.php';
  14.  
  15. $pb = new HTML_Progress2();
  16. $pb->setAnimSpeed(200);
  17. $pb->setIncrement(10);
  18. $pb->setOrientation(HTML_PROGRESS2_POLYGONAL);
  19. $pb->setCellAttributes('width=20 height=20');
  20. $pb->setLabelAttributes('pct1', 'valign=top align=center height=20');
  21. $w = $h = 3// square 3x3
  22. ?>
  23. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  24.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  25. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  26. <head>
  27. <title>Square Progress2 example</title>
  28. <style type="text/css">
  29. <!--
  30. <?php echo $pb->getStyle(); ?>
  31.  
  32. body {
  33.     background-color: #FFFFFF;
  34. }
  35.  -->
  36. </style>
  37. <?php echo $pb->getScript(false); ?>
  38. </head>
  39. <body>
  40.  
  41. <?php
  42. $pb->setCellCoordinates($w,$h);
  43. // reference coordinates (top left corner)
  44. $coord = $pb->getCellCoordinates();
  45.  
  46. // 1. begin at top left corner (default)
  47. $pb->display();
  48. $pb->run();
  49.  
  50. // 2. begin at top right corner
  51. $c = $coord;
  52. for ($i=1; $i<$w; $i++) {
  53.     $shift = array_shift($c);
  54.     array_push($c, $shift);
  55. }
  56. $pb->setCellCoordinates($w,$h,$c);
  57. $pb->setValue(0);
  58. $pb->display();
  59. $pb->run();
  60.  
  61. // 3. begin at bottom right corner
  62. $c = $coord;
  63. for ($i=1; $i<($w+$h-1); $i++) {
  64.     $shift = array_shift($c);
  65.     array_push($c, $shift);
  66. }
  67. $pb->setCellCoordinates($w,$h,$c);
  68. $pb->setValue(0);
  69. $pb->display();
  70. $pb->run();
  71.  
  72. // 4. begin at bottom left corner
  73. $c = $coord;
  74. for ($i=1; $i<$w; $i++) {
  75.     $pop = array_pop($c);
  76.     array_unshift($c, $pop);
  77. }
  78. $pb->setCellCoordinates($w,$h,$c);
  79. $pb->setValue(0);
  80. $pb->display();
  81. $pb->run();
  82. ?>
  83.  
  84. </body>
  85. </html>