Skip to content

Commit

Permalink
Merge pull request #198 from gabeyk9/main
Browse files Browse the repository at this point in the history
fix the variant error bugs hopefully
  • Loading branch information
balt-dev authored Nov 9, 2024
2 parents 89a5b4e + c1344bc commit 9a5b279
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cogs/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ async def pixelate(sprite, x: int, y: Optional[int] = None):
@add_variant()
async def posterize(sprite, bands: int):
"""Posterizes the sprite."""
return np.dstack([np.digitize(sprite[..., i], np.linspace(0, 255, bands)) * (255 / bands) for i in range(4)])
sprite = np.dstack([np.digitize(sprite[..., i], np.linspace(0, 255, bands)) * (255 / bands) for i in range(4)])
return sprite.astype(np.uint8)

@add_variant("m")
async def meta(sprite, level: Optional[int] = 1, kernel: Optional[Literal["full", "edge"]] = "full", size: Optional[int] = 1):
Expand Down Expand Up @@ -953,7 +954,7 @@ async def aberrate(sprite, x: Optional[int] = 1, y: Optional[int] = 0):
sprite[:, :, 3] += np.roll(np.roll(sprite[:, :, 3], -x, 1), -y, 0)
sprite[:, :, 3] += np.roll(np.roll(sprite[:, :, 3], x, 1), y, 0)
sprite[sprite > 255] = 255
return sprite
return sprite.astype(np.uint8)

@add_variant("alpha", "op")
async def opacity(sprite, amount: float):
Expand Down Expand Up @@ -1061,7 +1062,7 @@ async def saturation(sprite, saturation: Optional[float] = 0):
"""Saturates or desaturates a sprite."""
gray_sprite = sprite.copy()
gray_sprite[..., :3] = (sprite[..., 0] * 0.299 + sprite[..., 1] * 0.587 + sprite[..., 2] * 0.114)[..., np.newaxis]
return composite(gray_sprite, sprite, saturation)
return composite(gray_sprite, sprite, saturation).astype(np.uint8)

@add_variant()
async def blank(sprite):
Expand Down

0 comments on commit 9a5b279

Please sign in to comment.