Convert hex color to hsv.
public static hex_to_hsv ( string $hex ) : array | ||
$hex | string | The hex value of color 1. |
return | array | Returns array( 'h', 's', 'v' ). |
public function test_hex_to_hsv() { $white = array('h' => 0, 's' => 0, 'v' => 1); $black = array('h' => 0, 's' => 0, 'v' => 0); $red = array('h' => 0, 's' => 1, 'v' => 1); $green = array('h' => 0.33, 's' => 1, 'v' => 1); $blue = array('h' => 0.67, 's' => 1, 'v' => 1); $this->assertEquals($white, Kirki_Color::hex_to_hsv('#ffffff')); $this->assertEquals($black, Kirki_Color::hex_to_hsv('#000000')); $this->assertEquals($red, Kirki_Color::hex_to_hsv('#ff0000')); $this->assertEquals($green, Kirki_Color::hex_to_hsv('#00ff00')); $this->assertEquals($blue, Kirki_Color::hex_to_hsv('#0000ff')); }