Пример #1
0
 /**
  * Get an array with HSL color components
  *
  * @return array with keys ('hue', 'saturation', 'lightness', 'alpha')
  */
 public function toHslArray()
 {
     $rgb = new \Com\Tecnick\Color\Model\Rgb($this->toRgbArray());
     return $rgb->toHslArray();
 }
Пример #2
0
 public function testToHslArray()
 {
     $res = $this->obj->toHslArray();
     $this->assertEquals(array('hue' => 0.583, 'saturation' => 0.5, 'lightness' => 0.5, 'alpha' => 0.85), $res, '', 0.01);
     $col = new \Com\Tecnick\Color\Model\Rgb(array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 1));
     $res = $col->toHslArray();
     $this->assertEquals(array('hue' => 0, 'saturation' => 0, 'lightness' => 0, 'alpha' => 1), $res, '', 0.01);
     $col = new \Com\Tecnick\Color\Model\Rgb(array('red' => 0.1, 'green' => 0.3, 'blue' => 0.2, 'alpha' => 1));
     $res = $col->toHslArray();
     $this->assertEquals(array('hue' => 0.416, 'saturation' => 0.5, 'lightness' => 0.2, 'alpha' => 1), $res, '', 0.01);
     $col = new \Com\Tecnick\Color\Model\Rgb(array('red' => 0.3, 'green' => 0.2, 'blue' => 0.1, 'alpha' => 1));
     $res = $col->toHslArray();
     $this->assertEquals(array('hue' => 0.0833, 'saturation' => 0.5, 'lightness' => 0.2, 'alpha' => 1), $res, '', 0.01);
     $col = new \Com\Tecnick\Color\Model\Rgb(array('red' => 1, 'green' => 0.1, 'blue' => 0.9, 'alpha' => 1));
     $res = $col->toHslArray();
     $this->assertEquals(array('hue' => 0.852, 'saturation' => 1, 'lightness' => 0.55, 'alpha' => 1), $res, '', 0.01);
 }