1 | <?php namespace Arcanedev\Color\Converters; |
||
9 | trait HSVTrait |
||
10 | { |
||
11 | /* ------------------------------------------------------------------------------------------------ |
||
12 | | Main Functions |
||
13 | | ------------------------------------------------------------------------------------------------ |
||
14 | */ |
||
15 | /** |
||
16 | * Convert an RGB color to an HSV array (alias). |
||
17 | * |
||
18 | * @see fromRgbToHsv |
||
19 | * |
||
20 | * @param int $red |
||
21 | * @param int $green |
||
22 | * @param int $blue |
||
23 | * |
||
24 | * @return array |
||
25 | */ |
||
26 | 8 | public static function rgbToHsv($red, $green, $blue) |
|
30 | |||
31 | /** |
||
32 | * Convert an RGB color to an HSV array. |
||
33 | * |
||
34 | * @param int $red |
||
35 | * @param int $green |
||
36 | * @param int $blue |
||
37 | * |
||
38 | * @return array |
||
39 | */ |
||
40 | 16 | public function fromRgbToHsv($red, $green, $blue) |
|
72 | |||
73 | /** |
||
74 | * Convert an HSV color to an RGB array (alias). |
||
75 | * |
||
76 | * @see fromHsvToRgb |
||
77 | * |
||
78 | * @param float|int $hue |
||
79 | * @param float|int $saturation |
||
80 | * @param float|int $value |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | 8 | public static function hsvToRgb($hue, $saturation, $value) |
|
88 | |||
89 | /** |
||
90 | * Convert an HSV color to an RGB array. |
||
91 | * |
||
92 | * @param float|int $hue |
||
93 | * @param float|int $saturation |
||
94 | * @param float|int $value |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | 16 | public function fromHsvToRgb($hue, $saturation, $value) |
|
109 | |||
110 | /* ------------------------------------------------------------------------------------------------ |
||
111 | | Other Functions |
||
112 | | ------------------------------------------------------------------------------------------------ |
||
113 | */ |
||
114 | /** |
||
115 | * Calculate RGB with hue and chroma. |
||
116 | * |
||
117 | * @param float|int $hue |
||
118 | * @param float|int $chroma |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | 16 | protected function calculateRgbWithHueAndChroma($hue, $chroma) |
|
137 | |||
138 | /** |
||
139 | * Calculate X-Prime. |
||
140 | * |
||
141 | * @param float|int $hPrime |
||
142 | * @param float|int $chroma |
||
143 | * |
||
144 | * @return float|int |
||
145 | */ |
||
146 | 16 | protected function calculateXPrime($hPrime, $chroma) |
|
152 | |||
153 | /** |
||
154 | * Sanitize HSV value. |
||
155 | * |
||
156 | * @param int $value |
||
157 | * @param int $min |
||
158 | * @param int $max |
||
159 | * |
||
160 | * @return float|int |
||
161 | */ |
||
162 | 16 | protected function sanitizeHsvValue($value, $min, $max) |
|
169 | } |
||
170 |