コード例 #1
0
ファイル: RgbTest.php プロジェクト: sokil/php-image
 public function testFromHex()
 {
     $this->assertEquals(array(239, 239, 239, 0), Rgb::fromHex('#efefef')->toArray());
     $this->assertEquals(array(239, 239, 239, 0), Rgb::fromHex('efefef')->toArray());
     $this->assertEquals(array(239, 239, 239, 64), Rgb::fromHex('#80efefef')->toArray());
     $this->assertEquals(array(239, 239, 239, 64), Rgb::fromHex('80efefef')->toArray());
 }
コード例 #2
0
ファイル: Yiq.php プロジェクト: sokil/php-image
 /**
  * Get Q from RGB in YIQ color model
  * 
  * @param \Sokil\Image\ColorModel\Rgb $rgb 
  * @return int Q
  */
 public static function getQFromRgb(Rgb $rgb)
 {
     return floor($rgb->getRed() * 0.211 - $rgb->getGreen() * 0.522 + $rgb->getBlue() * 0.311);
 }