Utility-function to check that two hsv-colors are approximately equal >>> approximately_equal_hsv([0, 0, 0], [0, 0, 0]) True >>> approximately_equal_hsv([180, 0.5, 0.3], [179.9999, 0.500001, 0.30001]) True >>> approximately_equal_hsv([0, 0, 0], [1, 0, 0]) False >>>
(hsv_1: list[float], hsv_2: list[float])
| 140 | |
| 141 | |
| 142 | def approximately_equal_hsv(hsv_1: list[float], hsv_2: list[float]) -> bool: |
| 143 | """ |
| 144 | Utility-function to check that two hsv-colors are approximately equal |
| 145 | |
| 146 | >>> approximately_equal_hsv([0, 0, 0], [0, 0, 0]) |
| 147 | True |
| 148 | >>> approximately_equal_hsv([180, 0.5, 0.3], [179.9999, 0.500001, 0.30001]) |
| 149 | True |
| 150 | >>> approximately_equal_hsv([0, 0, 0], [1, 0, 0]) |
| 151 | False |
| 152 | >>> approximately_equal_hsv([180, 0.5, 0.3], [179.9999, 0.6, 0.30001]) |
| 153 | False |
| 154 | """ |
| 155 | check_hue = abs(hsv_1[0] - hsv_2[0]) < 0.2 |
| 156 | check_saturation = abs(hsv_1[1] - hsv_2[1]) < 0.002 |
| 157 | check_value = abs(hsv_1[2] - hsv_2[2]) < 0.002 |
| 158 | |
| 159 | return check_hue and check_saturation and check_value |
nothing calls this directly
no outgoing calls
no test coverage detected