async def color(self, ctx, *, color: discord.Color): '''Display info on a color.\n **Example:```yml\n♤color #8bb3f8```** ''' buffer = utils.display_color(color) r, g, b = color.to_rgb() c, m, y, k = utils.rgb_to_cmyk(*color.to_rgb()) h, s, l = utils.rgb_to_hsl(*color.to_rgb()) h, s_, v = utils.rgb_to_hsv(*color.to_rgb()) file = File(buffer, 'unknown.png') embed = Embed( description= '**[Color picker](https://www.google.com/search?q=color+picker)**', color=color) embed.set_author(name=color) embed.add_field(name='RGB', value=f'{r}, {g}, {b}') embed.add_field(name='CMYK', value=f'{c:.0%}, {m:.0%}, {y:.0%}, {k:.0%}') embed.add_field(name='HSL', value=f'{round(h)}°, {s:.0%}, {l:.0%}') embed.add_field(name='HSV', value=f'{round(h)}°, {s_:.0%}, {v:.0%}') embed.set_image(url='attachment://unknown.png') await ctx.send(file=file, embed=embed, reference=ctx.message.to_reference(), mention_author=False)
async def color(self, ctx, color: discord.Color): """Shows some info about provided color""" colorrgb = color.to_rgb() colorhsv = colorsys.rgb_to_hsv(colorrgb[0], colorrgb[1], colorrgb[2]) colorhls = colorsys.rgb_to_hls(colorrgb[0], colorrgb[1], colorrgb[2]) coloryiq = colorsys.rgb_to_yiq(colorrgb[0], colorrgb[1], colorrgb[2]) colorcmyk = rgb_to_cmyk(colorrgb[0], colorrgb[1], colorrgb[2]) em = discord.Embed(title=str(color), description="HEX: {}\n" "RGB: {}\n" "CMYK: {}\n" "HSV: {}\n" "HLS: {}\n" "YIQ: {}\n" "int: {}".format(hex(color.value).replace("0x", "#"), colorrgb, colorcmyk, colorhsv, colorhls, coloryiq, color.value), url='http://www.color-hex.com/color/{}'.format(hex(color.value).lstrip('0x')), colour=color, timestamp=ctx.message.created_at) em.set_thumbnail(url="https://xenforo.com/rgba.php?r={}&g={}&b={}&a=255" .format(colorrgb[0], colorrgb[1], colorrgb[2])) await ctx.send(embed=em)
async def color(self, ctx, color: discord.Color): """Shows some info about provided color""" colorrgb = color.to_rgb() colorhsv = colorsys.rgb_to_hsv(colorrgb[0], colorrgb[1], colorrgb[2]) colorhls = colorsys.rgb_to_hls(colorrgb[0], colorrgb[1], colorrgb[2]) coloryiq = colorsys.rgb_to_yiq(colorrgb[0], colorrgb[1], colorrgb[2]) colorcmyk = rgb_to_cmyk(colorrgb[0], colorrgb[1], colorrgb[2]) em = discord.Embed( title=str(color), description="HEX: {}\n" "RGB: {}\n" "CMYK: {}\n" "HSV: {}\n" "HLS: {}\n" "YIQ: {}\n" "int: {}".format( str(color), colorrgb, colorcmyk, colorhsv, colorhls, coloryiq, color.value, ), url=f"http://www.color-hex.com/color/{str(color)[1:]}", colour=color, timestamp=ctx.message.created_at, ) em.set_thumbnail( url=f"https://api.alexflipnote.dev/color/image/{str(color)[1:]}") em.set_image( url= f"https://api.alexflipnote.dev/color/image/gradient/{str(color)[1:]}" ) await ctx.send(embed=em)
async def color(self, ctx, *, color: discord.Color): """Shows some info about provided color.""" colorrgb = color.to_rgb() rgb_coords = [x / 255 for x in colorrgb] colorhsv = rgb_to_hsv(*colorrgb) h, l, s = colorsys.rgb_to_hls(*rgb_coords) colorhls = (colorhsv[0], l * 100, s * 100) coloryiq = colorsys.rgb_to_yiq(*rgb_coords) colorcmyk = rgb_to_cmyk(*colorrgb) colors_text = ( "`HEX :` {}\n" "`RGB :` {}\n" "`CMYK:` {}\n" "`HSV :` {}\n" "`HLS :` {}\n" "`YIQ :` {}\n" "`Int :` {}".format( str(color), colorrgb, tuple( map(lambda x: isinstance(x, float) and round(x, 2) or x, colorcmyk)), tuple( map(lambda x: isinstance(x, float) and round(x, 2) or x, colorhsv)), tuple( map(lambda x: isinstance(x, float) and round(x, 2) or x, colorhls)), tuple( map(lambda x: isinstance(x, float) and round(x, 2) or x, coloryiq)), color.value, )) em = discord.Embed( title=str(color), description=_("`Name:` Loading...\n") + colors_text, url=f"http://www.color-hex.com/color/{str(color)[1:]}", colour=color, timestamp=ctx.message.created_at, ) # CAUTION: That can fail soon em.set_thumbnail( url=f"https://api.alexflipnote.dev/color/image/{str(color)[1:]}") em.set_image( url= f"https://api.alexflipnote.dev/color/image/gradient/{str(color)[1:]}" ) m = await ctx.send(embed=em) async with self.session.get("https://www.thecolorapi.com/id", params={"hex": str(color)[1:]}) as data: color_response = await data.json(loads=json.loads) em.description = (_("`Name:` {} ({})\n").format( color_response.get("name", {}).get("value", "?"), color_response.get("name", {}).get("closest_named_hex", "?"), ) + colors_text) await m.edit(embed=em)
async def color(self, ctx, color: discord.Color = None): if color is None: return await ctx.send("Please provid a color.") color_string = str(color) color_string = color_string[1:] color_e = discord.Embed(color=color) color_e.add_field(name="Hex", value=color, inline=False) color_e.add_field(name="RGB", value=color.to_rgb(), inline=False) color_e.set_thumbnail( url=f"https://dummyimage.com/400x400/{color_string}/{color_string}" ) await ctx.send(embed=color_e)
def display_color(color: discord.Color) -> io.BytesIO: im = Image.new('RGB', (1200, 400), color.to_rgb()) draw = ImageDraw.Draw(im) font = ImageFont.truetype('assets/font/Comfortaa-Bold.ttf', 250) x, y = im.width, im.height w, h = font.getsize(str(color)) # Around 6,000,000 just happened to be the sweet spot for white text fill = 'black' if color.value > 6000000 else 'white' draw.text((x//2-w//2, y//2-h//2), str(color), font=font, fill=fill) buffer = io.BytesIO() im.save(buffer, 'png') buffer.seek(0) return buffer
def gen_banner(self, ctx, member_avatar, color: discord.Color): im = Image.new("RGBA", (489, 481), color.to_rgb()) comic = Image.open(f"{bundled_data_path(self)}/banner/banner.png", mode="r").convert("RGBA") member_avatar = self.bytes_to_image(member_avatar, 200) # 2nd slide av = member_avatar.rotate(angle=7, resample=Image.BILINEAR, expand=True) av = av.resize((90, 90), Image.LANCZOS) im.paste(av, (448, 38), av) # 3rd slide av2 = member_avatar.rotate(angle=7, resample=Image.BILINEAR, expand=True) av2 = av2.resize((122, 124), Image.LANCZOS) im.paste(av2, (47, 271), av2) # 4th slide av3 = member_avatar.rotate(angle=26, resample=Image.BILINEAR, expand=True) av3 = av3.resize((147, 148), Image.LANCZOS) im.paste(av2, (345, 233), av2) av.close() av2.close() av3.close() member_avatar.close() # cover = Image.open(f"{bundled_data_path(self)}/banner/bannercover.png", mode="r").convert("RGBA") # im.paste(cover, (240, 159), cover) im.paste(comic, (0, 0), comic) fp = BytesIO() im.save(fp, "PNG") fp.seek(0) im.close() _file = discord.File(fp, "banner.png") fp.close() return _file
async def color(self, ctx, *, color: discord.Color): """Shows some info about provided color.""" colorrgb = color.to_rgb() colorhsv = colorsys.rgb_to_hsv(colorrgb[0], colorrgb[1], colorrgb[2]) colorhls = colorsys.rgb_to_hls(colorrgb[0], colorrgb[1], colorrgb[2]) coloryiq = colorsys.rgb_to_yiq(colorrgb[0], colorrgb[1], colorrgb[2]) colorcmyk = rgb_to_cmyk(colorrgb[0], colorrgb[1], colorrgb[2]) colors_text = ( "HEX: {}\n" "RGB: {}\n" "CMYK: {}\n" "HSV: {}\n" "HLS: {}\n" "YIQ: {}\n" "int: {}".format( str(color), colorrgb, tuple(map(lambda x: isinstance(x, float) and round(x, 2) or x, colorcmyk)), tuple(map(lambda x: isinstance(x, float) and round(x, 2) or x, colorhsv)), tuple(map(lambda x: isinstance(x, float) and round(x, 2) or x, colorhls)), tuple(map(lambda x: isinstance(x, float) and round(x, 2) or x, coloryiq)), color.value, ) ) em = discord.Embed( title=str(color), description=_("Name: Loading...\n") + colors_text, url=f"http://www.color-hex.com/color/{str(color)[1:]}", colour=color, timestamp=ctx.message.created_at, ) em.set_thumbnail(url=f"https://api.alexflipnote.dev/color/image/{str(color)[1:]}") em.set_image(url=f"https://api.alexflipnote.dev/color/image/gradient/{str(color)[1:]}") m = await ctx.send(embed=em) async with self.session.get( f"https://api.alexflipnote.dev/color/{str(color)[1:]}" ) as data: color_name = (await data.json(loads=json.loads)).get("name", "?") em.description = _("Name: {}\n").format(color_name) + colors_text await m.edit(embed=em)