예제 #1
0
 public function line(awColor $color, awLine $line)
 {
     if ($line->thickness > 0 and $line->isHidden() === FALSE) {
         $rgb = $this->getColor($color);
         $thickness = $line->thickness;
         list($p1, $p2) = $line->getLocation();
         $this->startThickness($thickness);
         switch ($line->getStyle()) {
             case awLine::SOLID:
                 imageline($this->resource, $this->x + round($p1->x), $this->y + round($p1->y), $this->x + round($p2->x), $this->y + round($p2->y), $rgb);
                 break;
             case awLine::DOTTED:
                 $size = sqrt(pow($p2->y - $p1->y, 2) + pow($p2->x - $p1->x, 2));
                 $cos = ($p2->x - $p1->x) / $size;
                 $sin = ($p2->y - $p1->y) / $size;
                 for ($i = 0; $i <= $size; $i += 2) {
                     $p = new awPoint(round($i * $cos + $p1->x), round($i * $sin + $p1->y));
                     $this->point($color, $p);
                 }
                 break;
             case awLine::DASHED:
                 $width = $p2->x - $p1->x;
                 $height = $p2->y - $p1->y;
                 $size = sqrt(pow($height, 2) + pow($width, 2));
                 if ($size == 0) {
                     return;
                 }
                 $cos = $width / $size;
                 $sin = $height / $size;
                 $functionX = $width > 0 ? 'min' : 'max';
                 $functionY = $height > 0 ? 'min' : 'max';
                 for ($i = 0; $i <= $size; $i += 6) {
                     $t1 = new awPoint(round($i * $cos + $p1->x), round($i * $sin + $p1->y));
                     $t2 = new awPoint(round($functionX(($i + 3) * $cos, $width) + $p1->x), round($functionY(($i + 3) * $sin, $height) + $p1->y));
                     $this->line($color, new awLine($t1, $t2));
                 }
                 break;
         }
         $this->stopThickness($thickness);
     }
 }
예제 #2
0
 /**
  * Draw a colored line
  *
  * @param awColor $color Line color
  * @param awLine $line
  * @param int $thickness Line tickness
  */
 public function line(awColor $color, awLine $line)
 {
     if ($line->getThickness() > 0 and $line->isHidden() === FALSE) {
         list($red, $green, $blue, $alpha) = $this->getColor($color);
         $mingLine = new SWFShape();
         $mingLine->setLine($line->getThickness(), $red, $green, $blue, $alpha);
         list($p1, $p2) = $line->getLocation();
         $mingLine->movePenTo($this->x + round($p1->x), $this->y + round($p1->y));
         switch ($line->getStyle()) {
             case awLine::SOLID:
                 $mingLine->drawLineTo($this->x + round($p2->x), $this->y + round($p2->y));
                 $this->movie->add($mingLine);
                 break;
             case awLine::DOTTED:
                 $size = sqrt(pow($p2->y - $p1->y, 2) + pow($p2->x - $p1->x, 2));
                 $cos = ($p2->x - $p1->x) / $size;
                 $sin = ($p2->y - $p1->y) / $size;
                 for ($i = 0; $i <= $size; $i += 2) {
                     $p = new awPoint(round($i * $cos + $p1->x), round($i * $sin + $p1->y));
                     $this->point($color, $p);
                 }
                 break;
             case awLine::DASHED:
                 $width = $p2->x - $p1->x;
                 $height = $p2->y - $p1->y;
                 $size = sqrt(pow($height, 2) + pow($width, 2));
                 if ($size == 0) {
                     return;
                 }
                 $cos = $width / $size;
                 $sin = $height / $size;
                 $functionX = $width > 0 ? 'min' : 'max';
                 $functionY = $height > 0 ? 'min' : 'max';
                 for ($i = 0; $i <= $size; $i += 6) {
                     $t1 = new awPoint(round($i * $cos + $p1->x), round($i * $sin + $p1->y));
                     $t2 = new awPoint(round($functionX(($i + 3) * $cos, $width) + $p1->x), round($functionY(($i + 3) * $sin, $height) + $p1->y));
                     $this->line($color, new awLine($t1, $t2));
                 }
                 break;
         }
     }
 }