async def colour_info(self, ctx, *, colour: discord.Colour = None): """Get information on a colour. `colour:` The colour to get information on by hex or integer value. """ # If colour was not specified if colour is None: raise commands.BadArgument('You must specify a colour.') embed = discord.Embed( colour=colour ).set_author( name=f'Information on: {colour}' ).add_field( name='Hex:', value=colour ).add_field( name='RGB:', value=', '.join(str(c) for c in colour.to_rgb()) ).set_thumbnail( url=f'attachment://{colour.value:0>6x}.png' ) with io.BytesIO() as fp_out: img = Image.new('RGB', (80, 80)) img.paste(colour.to_rgb(), (0, 0, 80, 80)) img.save(fp_out, 'PNG') fp_out.seek(0) await ctx.send(embed=embed, file=discord.File(fp_out, f'{colour.value:0>6x}.png'))
async def getcolor( self, ctx, color: discord.Colour, width: int = 200, height: int = 90, show_hexcode=True, ): """displays a color from its name or hex value Parameters • color - the name or hexcode of the color to display • width - width of the image to display, defaults to 200 • height - height of the image to display, defaults to 90 • show_hexcode - whether to display the hexcode of the color, defaults to True """ file = io.BytesIO() Image.new("RGB", (width, height), color.to_rgb()).save(file, format="PNG") file.seek(0) if show_hexcode: em = discord.Embed(color=color, title=f"Showing Color: {str(color)}") elif show_hexcode == False or "false": em = discord.Embed(color=color) em.set_image(url="attachment://color.png") await ctx.send(file=discord.File(file, "color.png"), embed=em)
async def show_color(self, ctx, *, color: discord.Colour): '''Enter a color and you will see it!''' file = io.BytesIO() Image.new('RGB', (200, 90), color.to_rgb()).save(file, format='PNG') file.seek(0) em = discord.Embed(color=color, title=f'Цвет: {str(color)}') em.set_image(url='attachment://color.png') await ctx.send(file=discord.File(file, 'color.png'), embed=em)
async def show_color(self, ctx, *, color: discord.Colour): """Enter a color and you will see it!""" file = io.BytesIO() Image.new("RGB", (200, 90), color.to_rgb()).save(file, format="PNG") file.seek(0) em = Embed(color=color, title=f"Showing Color: {str(color)}") em.set_image(url="attachment://color.png") await ctx.send(file=discord.File(file, "color.png"), embed=em)
def profile_for(self, avatar: io.BytesIO, player: utils.Player, hide: bool = False, *, custombg: io.BytesIO = None, colour: discord.Colour = None): image = Image.open(avatar).convert("RGBA") image = image.resize((256, 256)) if not custombg: background = self.background.copy() else: background = Image.open(custombg).convert("RGBA") colour = colour.to_rgb() if colour else (255, 255, 255) background.paste(image, (0, 0), image) draw = ImageDraw.Draw(background) created = humanize.naturaltime(player.created_at) draw.text((5, 255), f"{player.name}\n{player.owner}\nCreated {created}", colour, self.font()) draw.text((265, 0), f"Tier {player.level}\n{player.exp} EXP", colour, self.font()) if player.status is utils.Status.idle: status = "Idling at" pmap = str(player.map) if not hide else "???" elif player.status is utils.Status.travelling: status = "Travelling to" pmap = str(player.next_map) if not hide else "???" elif player.status is utils.Status.exploring: status = "Exploring" pmap = str(player.map) if not hide else "???" else: status = "???" pmap = str(player.map) if not hide else "???" draw.text((265, 125), f"{status}\n{pmap}", colour, self.font()) draw.text((265, 205), f"{player.gold:,} G", colour, self.font()) n = io.BytesIO() background.save(n, "png") n.seek(0) return n
def make_mutated_color(colobj: discord.Colour): rgb = tuple([x / 255 for x in colobj.to_rgb()]) newrgb = [int(x * 255) for x in mutate(*rgb)] return discord.Colour.from_rgb(*newrgb)