コード例 #1
0
    async def change_magic_color(self, server):
        """Change magic role color."""
        if not self.magic_is_running:
            return

        server_settings = self.settings[server.id].copy()
        role_name = server_settings["role"]["name"]
        magic_role = discord.utils.get(server.roles, name=role_name)

        self.hue = self.hue + 10
        self.hue = self.hue % 360
        hex_ = hsluv.hsluv_to_hex((self.hue, 100, 60))
        # Remove # sign from hex
        hex_ = hex_[1:]
        new_color = discord.Color(value=int(hex_, 16))

        await self.bot.edit_role(
            server,
            magic_role,
            color=new_color)

        await self.verify_members(server, magic_role)

        await asyncio.sleep(self.interval)
        if self.magic_is_running:
            if self is self.bot.get_cog("Magic"):
                self.task = self.bot.loop.create_task(
                    self.change_magic_color(server))
コード例 #2
0
    def test_snapshot(self):
        for hex_color, colors in self.snapshot.items():
            # Test forward functions
            test_rgb = hex_to_rgb(hex_color)
            self.assert_tuples_close(test_rgb, colors['rgb'])
            test_xyz = rgb_to_xyz(test_rgb)
            self.assert_tuples_close(test_xyz, colors['xyz'])
            test_luv = xyz_to_luv(test_xyz)
            self.assert_tuples_close(test_luv, colors['luv'])
            test_lch = luv_to_lch(test_luv)
            self.assert_tuples_close(test_lch, colors['lch'])
            test_hsluv = lch_to_hsluv(test_lch)
            self.assert_tuples_close(test_hsluv, colors['hsluv'])
            test_hpluv = lch_to_hpluv(test_lch)
            self.assert_tuples_close(test_hpluv, colors['hpluv'])

            # Test backward functions
            test_lch = hsluv_to_lch(colors['hsluv'])
            self.assert_tuples_close(test_lch, colors['lch'])
            test_lch = hpluv_to_lch(colors['hpluv'])
            self.assert_tuples_close(test_lch, colors['lch'])
            test_luv = lch_to_luv(test_lch)
            self.assert_tuples_close(test_luv, colors['luv'])
            test_xyz = luv_to_xyz(test_luv)
            self.assert_tuples_close(test_xyz, colors['xyz'])
            test_rgb = xyz_to_rgb(test_xyz)
            self.assert_tuples_close(test_rgb, colors['rgb'])
            self.assertEqual(rgb_to_hex(test_rgb), hex_color)

            # Full test
            self.assertEqual(hsluv_to_hex(colors['hsluv']), hex_color)
            self.assert_tuples_close(hex_to_hsluv(hex_color), colors['hsluv'])
            self.assertEqual(hpluv_to_hex(colors['hpluv']), hex_color)
            self.assert_tuples_close(hex_to_hpluv(hex_color), colors['hpluv'])
コード例 #3
0
def colour_list(count,
                start=0,
                stop=360,
                chroma=100,
                lightness=50,
                chroma_var=5,
                lightness_var=5):
    out = []
    for c in range(count):
        # it's helpful to have some saturation and chroma variance.
        hue = start + c * stop / count
        chroma -= chroma_var * random.random()
        lightness += lightness_var * [0, 1, 0, -1][c % 4]
        out.append(hsluv.hsluv_to_hex([hue, chroma, lightness]))
    return out
コード例 #4
0
ファイル: vc.py プロジェクト: gbishop/vim-color
def replaceColorUnderCursor(r):
    """Replace the hex color"""
    # clip it so functions don't have to
    r[0] = r[0] % 360
    r[1] = max(0, min(100, r[1]))
    r[2] = max(0, min(100, r[2]))
    h = hsluv.hsluv_to_hex(r)
    col = vim.current.window.cursor[1]
    line = vim.current.line
    if hexcolor.match(line, col):
        line = list(line)
        line[col:col + 6] = list(h[1:])
        vim.current.line = "".join(line)
        if autoexec:
            execute()
コード例 #5
0
def generate_array(hex, type=None, num=9):
    # values = np.linspace(100, 0, 12)
    # l = np.linspace(98, 12, num)
    s = np.concatenate(([100], np.linspace(88, 68, num - 1, 1)))
    if type == "DULL":
        s = np.linspace(45, 35, num)
        l = np.linspace(98, 10, num)
    elif type == "BRIGHT":
        l = np.linspace(98, 25, num)
        s = np.linspace(90, 100, num)
    print("Lightness:", l)
    print("Saturation:", s)
    colors = []
    h, _, _ = hsluv.hex_to_hsluv(hex)
    for s2, l2 in zip(s, l):
        colors.append(hsluv.hsluv_to_hex([h, s2, l2]))
        # print(hsluv.hpluv_to_hex(h, s, p), h, s, p)
    return colors
コード例 #6
0
	scatter(iwak[~np.isnan(H),0], iwak[~np.isnan(H),1], c = RGB[~np.isnan(H)], marker = '.', alpha = 0.5, zorder = 2, linewidth = 0, s= 40)

	if f == 'Mouse17-130129.pickle':		
		title(f.split(".")[0]+'\n(excluded)', pad = 0)
	else:
		title(f.split(".")[0])

	if n == 0:
		gca().text(-0.15, 1.1, "a", transform = gca().transAxes, fontsize = 10, fontweight='bold')

	if n == len(files)-1:
		ax = gca()
		# colorbar
		from matplotlib.colorbar import ColorbarBase
		colors = [hsluv.hsluv_to_hex([i,85,45]) for i in np.arange(0, 361)]
		cmap= matplotlib.colors.ListedColormap(colors)
		# cmap.set_under("hsluv")
		# cmap.set_over("w")''''
		cax = inset_axes(ax, "40%", "10%",
		                   bbox_to_anchor=(1.2, 0.5, 1, 1),
		                   bbox_transform=ax.transAxes, 
		                   loc = 'lower left')
		cb1 = mpl.colorbar.ColorbarBase(cax, cmap=cmap,
		                                norm=matplotlib.colors.Normalize(vmin=0,vmax=360),
		                                orientation='horizontal')
		cb1.set_ticks([0,360])
		cb1.set_ticklabels(['0', r"$2\pi$"])
		cax.set_title("Wake", pad = 3)

コード例 #7
0
def hsl(h, s, l):
    return hsluv_to_hex([h, s, l])
コード例 #8
0
ファイル: color.py プロジェクト: theotheroracle/mirage
 def hex(self) -> str:
     rgb = hsluv_to_hex(self.hsluva)
     alpha = builtins.hex(int(self.alpha * 255))[2:]
     alpha = f"0{alpha}" if len(alpha) == 1 else alpha
     return f"{alpha if self.alpha < 1 else ''}{rgb}".lower()
コード例 #9
0
 def nextColor(val):
     nextHue = (refColor[0] + val * 360 / maxNum) % 360
     return hsluv.hsluv_to_hex([nextHue, refColor[1], refColor[2]])