def get_color_by_hsv( h: float, s: float, v: float, shades: int = 0, json: Optional[bool] = None, all: bool = False, units: Optional[bool] = None, ): """Look up colors by HSV (Hue Saturation Brightness/Value) values. Hue is a point on the color wheel from 0 to 360 where 0 is red, 120 is green, and 240 is blue. Saturation is a percentage value where 0% means faded, and 100% means full color. Brightness (or value) is a percentage value where 0% is black and 100% reveals the most color. Usage examples: color hsv 360 100 100 color hsv 0 0 0 color hsv 10 20 30 --shades --json --all --units :param h: Hue in degree angle (0.0 to 360.0 inclusive). :param s: Saturation % (0.0 to 100.0 inclusive). :param v: Brightness/Value % (0.0 to 100.0 inclusive). :param shades: Display different shades of the specified color. :param json: Display in JSON format. :param all: Bypass user configuration and display all keys. :param units: Bypass user configuration and display units. """ config = load_config_file() config.set_flags( shades=validate_shades_count(shades), json=validate_boolean_flag(json), all=validate_boolean_flag(all), units=validate_boolean_flag(units), ) h = normalize_degree_angle(h) s = normalize_percent_value(s) v = normalize_percent_value(v) print_color(config, Color(*hsv_to_rgb(h, s, v)))
def test_normalize_degree_angle_bad_arg(bad_arg): with pytest.raises(InputValueError) as err: normalize_degree_angle(bad_arg) assert "Bad degree angle" in str(err.value)
def test_normalize_degree_angle(arg, expected): output = normalize_degree_angle(arg) assert isinstance(output, float) assert output == expected