コード例 #1
0
ファイル: Drawer.class.php プロジェクト: remyyounes/dolibarr
	/**
	 * Draw a polygon
	 *
	 * @param awColor $color Polygon color
	 * @param Polygon A polygon
	 */
	public function polygon(awColor $color, awPolygon $polygon) {
		
		switch($polygon->getStyle()) {
		
			case awPolygon::SOLID :
				$thickness = $line->getThickness();
				$this->startThickness($thickness);
				$points = $this->getPolygonPoints($polygon);
				$rgb = $color->getColor($this->resource);
				imagepolygon($this->resource, $points, $polygon->count(), $rgb);
				$this->stopThickness($thickness);
				break;
				
			default :
			
				if($polygon->count() > 1) {
				
					$prev = $polygon->get(0);
					
					$line = new awLine;
					$line->setStyle($polygon->getStyle());
					$line->setThickness($polygon->getThickness());
					
					for($i = 1; $i < $polygon->count(); $i++) {
						$current = $polygon->get($i);
						$line->setLocation($prev, $current);
						$this->line($color, $line);
						$prev = $current;
					}
					
				}
		
		}
		
	}
コード例 #2
0
 /**
  * When passed a Color object, returns the corresponding
  * color identifier (driver dependant).
  *
  * @param awColor $color A Color object
  * @return array $rgba A color identifier representing the color composed of the given RGB components
  */
 public function getColor(awColor $color)
 {
     // Ming simply works with R, G, B and Alpha values.
     list($red, $green, $blue, $alpha) = $color->rgba();
     // However, the Ming alpha channel ranges from 255 (opaque) to 0 (transparent),
     // while the awColor alpha channel ranges from 0 (opaque) to 100 (transparent).
     // First, we convert from 0-100 to 0-255.
     $alpha = (int) ($alpha * 255 / 100);
     // Then from 0-255 to 255-0.
     $alpha = abs($alpha - 255);
     return array($red, $green, $blue, $alpha);
 }