Exemplo n.º 1
0
 /**
  * Draw a colored rectangle
  *
  * @param $color Rectangle color
  * @param $line Rectangle diagonale
  * @param $p2
  */
 function rectangle($color, $line)
 {
     list($p1, $p2) = $line->getLocation();
     // Get Red, Green, Blue and Alpha values for the line
     list($r, $g, $b, $a) = $this->getColor($color);
     // Calculate the coordinates of the two other points of the rectangle
     $p3 = new Point($p1->x, $p2->y);
     $p4 = new Point($p2->x, $p1->y);
     $side = new Line($p1, $p2);
     // Draw the four sides of the rectangle, clockwise
     if ($p1->x <= $p2->x and $p1->y <= $p2->y or $p1->x >= $p2->x and $p1->y >= $p2->y) {
         $side->setLocation($p1, $p4);
         $this->line($color, $side);
         $side->setLocation($p4, $p2);
         $this->line($color, $side);
         $side->setLocation($p2, $p3);
         $this->line($color, $side);
         $side->setLocation($p3, $p1);
         $this->line($color, $side);
     } else {
         $side->setLocation($p1, $p3);
         $this->line($color, $side);
         $side->setLocation($p3, $p2);
         $this->line($color, $side);
         $side->setLocation($p2, $p4);
         $this->line($color, $side);
         $side->setLocation($p4, $p1);
         $this->line($color, $side);
     }
 }
Exemplo n.º 2
0
	 function rectangle($color, $line) {
	
		list($p1, $p2) = $line->getLocation();
		
		switch($line->getStyle()) {
		
			case LINE_SOLID :
				$thickness = $line->getThickness();
				$this->startThickness($thickness);
				$rgb = $this->getColor($color);
				imagerectangle($this->resource, $this->x + $p1->x, $this->y + $p1->y, $this->x + $p2->x, $this->y + $p2->y, $rgb);
				$this->stopThickness($thickness);
				break;
			
			default :
				
				
				$side = new Line($p1, $p2);
				
				
				// Top side
				$side->setLocation(
					new awPoint($p1->x, $p1->y),
					new awPoint($p2->x, $p1->y)
				);
				$this->line($color, $side);
				
				// Right side
				$side->setLocation(
					new awPoint($p2->x, $p1->y),
					new awPoint($p2->x, $p2->y)
				);
				$this->line($color, $side);
				
				// Bottom side
				$side->setLocation(
					new awPoint($p1->x, $p2->y),
					new awPoint($p2->x, $p2->y)
				);
				$this->line($color, $side);
				
				// Left side
				$side->setLocation(
					new awPoint($p1->x, $p1->y),
					new awPoint($p1->x, $p2->y)
				);
				$this->line($color, $side);
			
				break;
		
		}
	
	}