Python colorsys.hls_to_rgb() Examples
The following are 30
code examples of colorsys.hls_to_rgb().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
colorsys
, or try the search function
.
Example #1
Source File: plot_filters.py From kymatio with BSD 3-Clause "New" or "Revised" License | 6 votes |
def colorize(z): n, m = z.shape c = np.zeros((n, m, 3)) c[np.isinf(z)] = (1.0, 1.0, 1.0) c[np.isnan(z)] = (0.5, 0.5, 0.5) idx = ~(np.isinf(z) + np.isnan(z)) A = (np.angle(z[idx]) + np.pi) / (2*np.pi) A = (A + 0.5) % 1.0 B = 1.0/(1.0 + abs(z[idx])**0.3) c[idx] = [hls_to_rgb(a, b, 0.8) for a, b in zip(A, B)] return c ############################################################################### # Bandpass filters # ---------------- # First, we display each wavelet according to its scale and orientation.
Example #2
Source File: test_colorsys.py From BinderFilter with MIT License | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #3
Source File: mmvt_utils.py From mmvt with GNU General Public License v3.0 | 6 votes |
def get_selected_fcurves_colors(selected_objects_types, sepcific_obj_name='', exclude=()): import colorsys if not isinstance(selected_objects_types, Iterable): selected_objects_types = [selected_objects_types] selected_objects = [obj for obj in bpy.context.scene.objects if obj.select if check_obj_type(obj.name) in selected_objects_types] selected_objects = [obj for obj in selected_objects if obj.animation_data is not None and obj.name not in exclude][::-1] if len(selected_objects) == 0: return [] selected_objects_len = 6 if len(selected_objects) <= 6 else len(selected_objects) Hs = np.linspace(0, 360, selected_objects_len + 1)[:-1] / 360 obj_colors = [colorsys.hls_to_rgb(Hs[obj_ind], 0.5, 1) for obj_ind, obj in enumerate(selected_objects)] if sepcific_obj_name != '': selected_objects_names = [o.name for o in selected_objects] if sepcific_obj_name in selected_objects_names: return obj_colors[selected_objects_names.index(sepcific_obj_name)] return obj_colors
Example #4
Source File: test_colorsys.py From oss-ftp with MIT License | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #5
Source File: misc.py From SEM with MIT License | 6 votes |
def random_color(): import random, colorsys red = (random.randrange(0, 256) + 256) / 2.0; green = (random.randrange(0, 256) + 256) / 2.0; blue = (random.randrange(0, 256) + 256) / 2.0; def to_hex(i): hx = hex(int(i))[2:] if len(hx) == 1: hx = "0" + hx return hx def to_color(r,g,b): cs = [to_hex(c) for c in [r,g,b]] return "#{cs[0]}{cs[1]}{cs[2]}".format(cs=cs) def darker(r,g,b): h,l,s = colorsys.rgb_to_hls(r/256.0, g/256.0, b/256.0) cs = [to_hex(256.0*c) for c in colorsys.hls_to_rgb(h,l/2.5,s)] return "#{cs[0]}{cs[1]}{cs[2]}".format(cs=cs) return {"background":to_color(red,green,blue),"foreground":darker(red,green,blue)}
Example #6
Source File: color.py From pydantic with MIT License | 6 votes |
def parse_hsl(h: str, h_units: str, sat: str, light: str, alpha: Optional[float] = None) -> RGBA: """ Parse raw hue, saturation, lightness and alpha values and convert to RGBA. """ s_value, l_value = parse_color_value(sat, 100), parse_color_value(light, 100) h_value = float(h) if h_units in {None, 'deg'}: h_value = h_value % 360 / 360 elif h_units == 'rad': h_value = h_value % rads / rads else: # turns h_value = h_value % 1 r, g, b = hls_to_rgb(h_value, l_value, s_value) return RGBA(r, g, b, alpha)
Example #7
Source File: ChangeHue.py From pokemon with MIT License | 6 votes |
def shift(color, amount): r, g, b, a = color print(("rgb", r, g, b, a)) h, l, s = colorsys.rgb_to_hls(r, g, b) print(("hls", h, l, s)) h *= 360 h += int(amount) h %= 360 h /= 360.0 print(("hls", h, l, s)) r, g, b = colorsys.hls_to_rgb(h, l, s) print(("rgb", int(r), int(g), int(b), a)) return (int(r), int(g), int(b), a)
Example #8
Source File: CryptoIdentifier.py From grap with MIT License | 6 votes |
def gen_color(self): """Generate a color. Returns: (int): The return value is an rgb color. """ if self.n_assigned_colors < len(self.preferred_colors): hue = self.preferred_colors[self.n_assigned_colors][0] sat = self.preferred_colors[self.n_assigned_colors][1] self.n_assigned_colors += 1 else: hue = random.random() sat = random.random() rgb = colorsys.hls_to_rgb(hue, self._LIGHTNESS, sat) return ColorCore.rgb_to_int(rgb)
Example #9
Source File: test_colorsys.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #10
Source File: models.py From clist with Apache License 2.0 | 6 votes |
def save(self, *args, **kwargs): if self.color is None: values = [] for r in Resource.objects.filter(color__isnull=False): color = [int(r.color[i:i + 2], 16) / 255. for i in range(1, 6, 2)] h, _, _ = colorsys.rgb_to_hls(*color) values.append(h) values.sort() if values: prv = values[-1] - 1 opt = 0, 0 for val in values: delta, middle, prv = val - prv, (val + prv) * .5, val opt = max(opt, (delta, middle)) h = opt[1] % 1 color = colorsys.hls_to_rgb(h, .6, .5) self.color = '#' + ''.join(f'{int(c * 255):02x}' for c in color).upper() super().save(*args, **kwargs)
Example #11
Source File: test_colorsys.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #12
Source File: test_colorsys.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #13
Source File: test_colorsys.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #14
Source File: test_colorsys.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #15
Source File: test_colorsys.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #16
Source File: visgraph.py From Python-DevOps with MIT License | 6 votes |
def make_colors( self, node ): # return (group number, fill color, text color) if self.colored: idx, H = self.get(node) L = max([1.0 - 0.1 * node.get_level(), 0.1]) S = 1.0 A = 0.7 # make nodes translucent (to handle possible overlaps) fill_RGBA = self.htmlize_rgb(*colorsys.hls_to_rgb(H, L, S), A = A) # black text on light nodes, white text on (very) dark nodes. text_RGB = '#000000' if L >= 0.5 else '#ffffff' else: idx, _ = self.get(node) fill_RGBA = self.htmlize_rgb(1.0, 1.0, 1.0, 0.7) text_RGB = '#000000' return idx, fill_RGBA, text_RGB
Example #17
Source File: colors.py From flavio with MIT License | 6 votes |
def lighten_color(color, amount=0.5): """ Lightens the given color by multiplying (1-luminosity) by the given amount. Input can be matplotlib color string, hex string, or RGB tuple. Examples: >> lighten_color('g', 0.3) >> lighten_color('#F034A3', 0.6) >> lighten_color((.3,.55,.1), 0.5) """ import matplotlib.colors as mc import colorsys try: c = mc.cnames[color] except: c = color c = colorsys.rgb_to_hls(*mc.to_rgb(c)) return colorsys.hls_to_rgb(c[0], 1 - amount * (1 - c[1]), c[2])
Example #18
Source File: colors.py From flavio with MIT License | 6 votes |
def darken_color(color, amount=0.5): """ Darkens the given color by multiplying luminosity by the given amount. Input can be matplotlib color string, hex string, or RGB tuple. Examples: >> lighten_color('g', 0.3) >> lighten_color('#F034A3', 0.6) >> lighten_color((.3,.55,.1), 0.5) """ import matplotlib.colors as mc import colorsys try: c = mc.cnames[color] except: c = color c = colorsys.rgb_to_hls(*mc.to_rgb(c)) return colorsys.hls_to_rgb(c[0], amount * c[1], c[2])
Example #19
Source File: Color.py From ColorWallpaper with GNU General Public License v3.0 | 6 votes |
def from_hsl(h: int, s: int, l: int) -> "Color": """Creates a Color object from hue, saturation and luminance :param h: Hue :param s: Saturation :param l: Luminance :return: New Color object """ components = (360, h, "h"), (100, l, "l"), (100, s, "s") for bound, component, name in components: if not 0 <= component <= bound: raise ValueError(f"{name} is outside of [0, {bound}]: {component}") rgb = hls_to_rgb(*(component / bound for bound, component, name in components)) return Color(int_tuple(component * 255 for component in rgb))
Example #20
Source File: visualizer.py From detectron2 with Apache License 2.0 | 6 votes |
def _change_color_brightness(self, color, brightness_factor): """ Depending on the brightness_factor, gives a lighter or darker color i.e. a color with less or more saturation than the original color. Args: color: color of the polygon. Refer to `matplotlib.colors` for a full list of formats that are accepted. brightness_factor (float): a value in [-1.0, 1.0] range. A lightness factor of 0 will correspond to no change, a factor in [-1.0, 0) range will result in a darker color and a factor in (0, 1.0] range will result in a lighter color. Returns: modified_color (tuple[double]): a tuple containing the RGB values of the modified color. Each value in the tuple is in the [0.0, 1.0] range. """ assert brightness_factor >= -1.0 and brightness_factor <= 1.0 color = mplc.to_rgb(color) polygon_color = colorsys.rgb_to_hls(*mplc.to_rgb(color)) modified_lightness = polygon_color[1] + (brightness_factor * polygon_color[1]) modified_lightness = 0.0 if modified_lightness < 0.0 else modified_lightness modified_lightness = 1.0 if modified_lightness > 1.0 else modified_lightness modified_color = colorsys.hls_to_rgb(polygon_color[0], modified_lightness, polygon_color[2]) return modified_color
Example #21
Source File: widget.py From IDArling with GNU General Public License v3.0 | 6 votes |
def make_icon(template, color): """ Create an icon for the specified user color. It will be used to generate on the fly an icon representing the user. """ # Get a light and dark version of the user color r, g, b = StatusWidget.ida_to_python(color) h, l, s = colorsys.rgb_to_hls(r, g, b) r, g, b = colorsys.hls_to_rgb(h, 0.5, 1.0) light = StatusWidget.python_to_qt(r, g, b) r, g, b = colorsys.hls_to_rgb(h, 0.25, 1.0) dark = StatusWidget.python_to_qt(r, g, b) # Replace the icon pixel with our two colors image = QImage(template) for x in range(image.width()): for y in range(image.height()): c = image.pixel(x, y) if (c & 0xFFFFFF) == 0xFFFFFF: image.setPixel(x, y, light) if (c & 0xFFFFFF) == 0x000000: image.setPixel(x, y, dark) return QPixmap(image)
Example #22
Source File: test_colorsys.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #23
Source File: test_colorsys.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_hls_values(self): values = [ # rgb, hls ((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black ((0.0, 0.0, 1.0), (4./6., 0.5, 1.0)), # blue ((0.0, 1.0, 0.0), (2./6., 0.5, 1.0)), # green ((0.0, 1.0, 1.0), (3./6., 0.5, 1.0)), # cyan ((1.0, 0.0, 0.0), ( 0 , 0.5, 1.0)), # red ((1.0, 0.0, 1.0), (5./6., 0.5, 1.0)), # purple ((1.0, 1.0, 0.0), (1./6., 0.5, 1.0)), # yellow ((1.0, 1.0, 1.0), ( 0 , 1.0, 0.0)), # white ((0.5, 0.5, 0.5), ( 0 , 0.5, 0.0)), # grey ] for (rgb, hls) in values: self.assertTripleEqual(hls, colorsys.rgb_to_hls(*rgb)) self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
Example #24
Source File: visualizer.py From detectron2 with Apache License 2.0 | 6 votes |
def _change_color_brightness(self, color, brightness_factor): """ Depending on the brightness_factor, gives a lighter or darker color i.e. a color with less or more saturation than the original color. Args: color: color of the polygon. Refer to `matplotlib.colors` for a full list of formats that are accepted. brightness_factor (float): a value in [-1.0, 1.0] range. A lightness factor of 0 will correspond to no change, a factor in [-1.0, 0) range will result in a darker color and a factor in (0, 1.0] range will result in a lighter color. Returns: modified_color (tuple[double]): a tuple containing the RGB values of the modified color. Each value in the tuple is in the [0.0, 1.0] range. """ assert brightness_factor >= -1.0 and brightness_factor <= 1.0 color = mplc.to_rgb(color) polygon_color = colorsys.rgb_to_hls(*mplc.to_rgb(color)) modified_lightness = polygon_color[1] + (brightness_factor * polygon_color[1]) modified_lightness = 0.0 if modified_lightness < 0.0 else modified_lightness modified_lightness = 1.0 if modified_lightness > 1.0 else modified_lightness modified_color = colorsys.hls_to_rgb(polygon_color[0], modified_lightness, polygon_color[2]) return modified_color
Example #25
Source File: tools.py From embeddings with Apache License 2.0 | 5 votes |
def _get_colors(num_colors): colors=[] for i in np.arange(0., 360., 360. / num_colors): hue = i/360. lightness = (50 + np.random.rand() * 10)/100. saturation = (90 + np.random.rand() * 10)/100. colors.append(colorsys.hls_to_rgb(hue, lightness, saturation)) return colors #colors = ['g','c','r','b','m','k','y',"orange",'indigo','salmon','crimson','hotpink','saddlebrown','lightgreen','yellowgreen','peru','gray','darkred']
Example #26
Source File: rgba.py From ColorHelper with MIT License | 5 votes |
def fromhls(self, h, l, s): """Convert to `RGB` from `HSL`.""" r, g, b = hls_to_rgb(h, l, s) self.r = clamp(round_int(r * 255.0), 0, 255) self.g = clamp(round_int(g * 255.0), 0, 255) self.b = clamp(round_int(b * 255.0), 0, 255)
Example #27
Source File: mmvt_utils.py From mmvt with GNU General Public License v3.0 | 5 votes |
def get_distinct_colors(colors_num=1): hs = get_distinct_colors_hs(colors_num) return [colorsys.hls_to_rgb(hs[ind], 0.5, 1) for ind in range(colors_num)]
Example #28
Source File: cdr_utils.py From uniconvertor with GNU Affero General Public License v3.0 | 5 votes |
def parse_hls(data): """ Parses HLS color bytes and returns fill style list. """ h = word2py_int(data[0:2]) / 360.0 l = ord(data[2]) / 255.0 s = ord(data[3]) / 255.0 r, g, b = hls_to_rgb(h, l, s) return [uc2const.COLOR_RGB, [r, g, b], 1.0, '']
Example #29
Source File: color.py From pyray with MIT License | 5 votes |
def colorFromAngle2(angle, h=136, s=118, maxx = 0.8): """ Converts simple numbers into colors using HSL color scale. This can be used to shade surfaces more exposed to light brighter. args: angle: Higher values of this argument correspond to brighter colors. If a plane of a polyhedron makes a large angle with a light source, it will look brighter. """ l = 96+64*angle/maxx #/450 r, g, b = colorsys.hls_to_rgb(h/255.0, l/255.0, s/255.0) r, g, b = [x*255.0 for x in (r, g, b)] return (int(r),int(g),int(b))
Example #30
Source File: test_colorsys.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_hls_roundtrip(self): for r in frange(0.0, 1.0, 0.2): for g in frange(0.0, 1.0, 0.2): for b in frange(0.0, 1.0, 0.2): rgb = (r, g, b) self.assertTripleEqual( rgb, colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb)) )