コード例 #1
0
 /**
  * Creates a palette from a gradient between $color1 and $color2
  *
  * @static
  * @param Color $color1 start color
  * @param Color $color2 end color
  * @param int   $shades number of colors to create
  * @return Palette
  */
 public static function colorGradientPalette(Color $color1, Color $color2, $shades)
 {
     $palette = new Palette();
     $RFactor = ($color2->getR() - $color1->getR()) / $shades;
     $GFactor = ($color2->getG() - $color1->getG()) / $shades;
     $BFactor = ($color2->getB() - $color1->getB()) / $shades;
     for ($i = 0; $i <= $shades - 1; $i++) {
         $palette->colors[$i] = new Color($color1->getR() + $RFactor * $i, $color1->getG() + $GFactor * $i, $color1->getB() + $BFactor * $i);
     }
     return $palette;
 }
コード例 #2
0
ファイル: Color.php プロジェクト: stdtabs/phptabs
 /**
  * Copies a color from another one
  * @param Color $color
  * @return void
  */
 public function copyFrom(Color $color)
 {
     $this->setR($color->getR());
     $this->setG($color->getG());
     $this->setB($color->getB());
 }
コード例 #3
0
 /**
  * return int which desribes allocate color for drawing
  *
  * @param resource $image
  * @return int
  */
 protected function _getDrawColor($image)
 {
     return imagecolorallocatealpha($image, $this->_color->getR(), $this->_color->getG(), $this->_color->getB(), $this->_transparency->getTransparency());
 }