/**
  * Draw all circle segment pictures
  *
  * @param      string    $dir           (optional) Directory where pictures should be created
  * @param      string    $fileMask      (optional) sprintf format for pictures filename
  *
  * @return     array
  * @since      1.2.0RC1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function drawCircleSegments($dir = '.', $fileMask = 'c%s.png')
 {
     if (!is_string($dir)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$dir', 'was' => gettype($dir), 'expected' => 'string', 'paramnum' => 1));
     } elseif (!is_string($fileMask)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$fileMask', 'was' => gettype($fileMask), 'expected' => 'string', 'paramnum' => 2));
     }
     include_once 'Image/Color.php';
     $cellAttr = $this->getCellAttributes();
     $cellCount = $this->getCellCount();
     $w = $cellAttr['width'];
     $h = $cellAttr['height'];
     $s = $cellAttr['spacing'];
     $c = intval(360 / $cellCount);
     $cx = floor($w / 2);
     if (fmod($w, 2) == 0) {
         $cx = $cx - 0.5;
     }
     $cy = floor($h / 2);
     if (fmod($h, 2) == 0) {
         $cy = $cy - 0.5;
     }
     $image = imagecreate($w, $h);
     $bg = Image_Color::allocateColor($image, $cellAttr['background-color']);
     $colorA = Image_Color::allocateColor($image, $cellAttr['active-color']);
     $colorI = Image_Color::allocateColor($image, $cellAttr['inactive-color']);
     imagefilledarc($image, $cx, $cy, $w, $h, 0, 360, $colorI, IMG_ARC_EDGED);
     $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask, 0);
     imagepng($image, $filename);
     $this->setCellAttributes(array('background-image' => $filename), 0);
     for ($i = 0; $i < $cellCount; $i++) {
         if ($this->getFillWay() == 'natural') {
             $sA = $i * $c;
             $eA = ($i + 1) * $c;
             $sI = ($i + 1) * $c;
             $eI = 360;
         } else {
             $sA = 360 - ($i + 1) * $c;
             $eA = 360 - $i * $c;
             $sI = 0;
             $eI = 360 - ($i + 1) * $c;
         }
         if ($s > 0) {
             imagefilledarc($image, $cx, $cy, $w, $h, 0, $sA, $colorI, IMG_ARC_EDGED);
         }
         imagefilledarc($image, $cx, $cy, $w, $h, $sA, $eA, $colorA, IMG_ARC_EDGED);
         imagefilledarc($image, $cx, $cy, $w, $h, $sI, $eI, $colorI, IMG_ARC_EDGED);
         $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask, $i + 1);
         imagepng($image, $filename);
         $this->setCellAttributes(array('background-image' => $filename), $i + 1);
     }
     imagedestroy($image);
 }