def generate(self, **kwargs): colors = [] lower = kwargs['at_least'] if 'at_least' in kwargs else 1 upper = kwargs['at_most'] if 'at_most' in kwargs else 10 amount = kwargs['exactly'] if 'exactly' in kwargs else random.randint(lower, upper) step = 1 / amount base = random.uniform(0.0, 1.0) lightness = random.uniform(0.2, 0.8) saturation = random.uniform(0.4, 0.8) hues = [base + i * step for i in range(amount)] for hue in hues: if hue < 0.0 or hue > 1.0: hue -= math.floor(hue) colors.append(imgen.hsl2rgb(imgen.hsl(hue, saturation, lightness))) return colors
def generate(self, **kwargs): colors = [] lower = kwargs['at_least'] if 'at_least' in kwargs else 1 upper = kwargs['at_most'] if 'at_most' in kwargs else 10 amount = kwargs['exactly'] if 'exactly' in kwargs else random.randint( lower, upper) base = random.uniform(0.0, 1.0) lightness = random.uniform(0.2, 0.8) saturation = random.uniform(0.4, 1.0) step = 0.4 / amount hues = [base + i * step for i in range(amount)] for hue in hues: if hue < 0.0 or hue > 1.0: hue -= math.floor(hue) colors.append(imgen.hsl2rgb(imgen.hsl(hue, lightness, saturation))) return colors
def generate(self, **kwargs): colors = [] lower = kwargs['at_least'] if 'at_least' in kwargs else 3 upper = kwargs['at_most'] if 'at_most' in kwargs else 6 amount = kwargs['exactly'] if 'exactly' in kwargs else random.randint(lower, upper) base = random.uniform(0.2, 0.8) hue = random.uniform(0.0, 1.0) saturation = random.uniform(0.4, 0.8) lightnesses = [ base + (i / amount) for i in range(amount) ] for lightness in lightnesses: if lightness < 0.0 or lightness > 1.0: lightness -= math.floor(lightness) colors.append( imgen.hsl2rgb(imgen.hsl(hue, saturation, lightness)) ) return colors