diff options
-rw-r--r-- | bot/exts/evergreen/profile_pic_modification/_effects.py | 17 | ||||
-rw-r--r-- | bot/exts/evergreen/profile_pic_modification/pfp_modify.py | 9 |
2 files changed, 19 insertions, 7 deletions
diff --git a/bot/exts/evergreen/profile_pic_modification/_effects.py b/bot/exts/evergreen/profile_pic_modification/_effects.py index 9319a1b8..a1069db7 100644 --- a/bot/exts/evergreen/profile_pic_modification/_effects.py +++ b/bot/exts/evergreen/profile_pic_modification/_effects.py @@ -10,9 +10,9 @@ from bot.constants import Colours class PfpEffects: """ - Implements various image effects. + Implements various image modifying effects, for the PfpModify cog. - All of these methods are blocking, so should be ran in threads. + All of these fuctions are slow, and blocking, so should be ran in executors. """ @staticmethod @@ -31,7 +31,7 @@ class PfpEffects: @staticmethod def closest(x: t.Tuple[int, int, int]) -> t.Tuple[int, int, int]: """ - Finds the closest easter colour to a given pixel. + Finds the closest "easter" colour to a given pixel. Returns a merge between the original colour and the closest colour. """ @@ -71,7 +71,7 @@ class PfpEffects: @staticmethod def pridify_effect(image: Image, pixels: int, flag: str) -> Image: - """Applies the pride effect to the given image.""" + """Applies the given pride effect to the given image.""" image = image.resize((1024, 1024)) image = PfpEffects.crop_avatar_circle(image) @@ -96,7 +96,14 @@ class PfpEffects: @staticmethod def easterify_effect(image: Image, overlay_image: Image = None) -> Image: - """Applies the easter effect to the given image.""" + """ + Applies the easter effect to the given image. + + This is done by getting the closest "easter" colour to each pixel and changing the colour + to the half-way RGBvalue. + + We also then add an overlay image on top in middle right, a chocolate bunny by default. + """ if overlay_image: ratio = 64 / overlay_image.height overlay_image = overlay_image.resize(( diff --git a/bot/exts/evergreen/profile_pic_modification/pfp_modify.py b/bot/exts/evergreen/profile_pic_modification/pfp_modify.py index d41fcaad..19f0bdf0 100644 --- a/bot/exts/evergreen/profile_pic_modification/pfp_modify.py +++ b/bot/exts/evergreen/profile_pic_modification/pfp_modify.py @@ -25,7 +25,12 @@ with open('bot/resources/pride/gender_options.json') as f: async def in_executor(func: t.Callable, *args) -> t.Any: - """Allows non-async functions to work in async functions.""" + """ + Runs the given synchronus function `func` in an executor. + + This is useful for running slow, blocking code within async + functions, so that they don't block the bot. + """ log.trace(f"Running {func.__name__} in an executor.") loop = asyncio.get_event_loop() return await loop.run_in_executor(_EXECUTOR, func, *args) @@ -233,7 +238,7 @@ class PfpModify(commands.Cog): brief='Spookify an user\'s avatar.' ) async def spooky_avatar(self, ctx: commands.Context, user: discord.Member = None) -> None: - """A command to print the user's spookified avatar.""" + """This "spookifies" the given user's avatar, with a random *spooky* effect.""" if user is None: user = ctx.message.author |