# Path: sc8pr/util.py
# def rgba(*args):
#     "Return a color or list of colors from str or tuple data"
#     c = list(_rgba(*args))
#     return c[0] if len(c) == 1 else c
# 
# def style(srf, bg=None, border=(0,0,0), weight=0, padding=0, borderradius=None):
#     "Create a new surface with padding, background color, and/or border"
#     w, h = srf.get_size()
# 
#     # Add padding
#     if type(padding) is int: px = py = padding + weight
#     else: px, py = [p + weight for p in padding]
#     w += 2 * px
#     h += 2 * py
#     img = pygame.Surface((w, h), pygame.SRCALPHA)
# 
#     # Add background color and border
#     if bg: img.fill(rgba(bg))
#     img.blit(srf, (px, py))
#     if weight: drawBorder(img, border, weight)
#     if borderradius: img = borderRadius(img, borderradius)
# 
#     return img


from random import uniform, random
from math import sqrt, tan, pi, sin, cos, hypot
from sys import stderr
from pygame.pixelarray import PixelArray
from sc8pr.util import rgba, style
    from pygame.surfarray import pixels_alpha
import pygame
class Squash(Wipe):

    @staticmethod
    def _apply(srf, pos, size, origSize):
        "Blit the scaled image onto a transparent background"
        srf = pygame.transform.smoothscale(srf, size)
        img = pygame.Surface(origSize, pygame.SRCALPHA)
        img.blit(srf, pos)
        return img


class MathEffect(Effect):
    "Effect based on y < f(x) or y > f(x)"

    def __init__(self, noise=0.15, fill=(0,0,0,0)):
        self.fill = rgba(fill)
        self.above = noise > 0
        self.noise = abs(noise)

    def eqn(self, x, n, size):
        dh = self.noise
        if not self.above: n = 1 - n
        return size[1] * ((1 + dh) * n - uniform(0, dh)), self.above

    def apply(self, img, n=0):
        "Modify image based on equation provided"
        if n >= 1: return img
        srf, size = self.srfSize(img, True)
        h = size[1]
        pxa = PixelArray(srf)

# Path: sc8pr/util.py
# def rgba(*args):
#     "Return a color or list of colors from str or tuple data"
#     c = list(_rgba(*args))
#     return c[0] if len(c) == 1 else c
# 
# def style(srf, bg=None, border=(0,0,0), weight=0, padding=0, borderradius=None):
#     "Create a new surface with padding, background color, and/or border"
#     w, h = srf.get_size()
# 
#     # Add padding
#     if type(padding) is int: px = py = padding + weight
#     else: px, py = [p + weight for p in padding]
#     w += 2 * px
#     h += 2 * py
#     img = pygame.Surface((w, h), pygame.SRCALPHA)
# 
#     # Add background color and border
#     if bg: img.fill(rgba(bg))
#     img.blit(srf, (px, py))
#     if weight: drawBorder(img, border, weight)
#     if borderradius: img = borderRadius(img, borderradius)
# 
#     return img


# Path: sc8pr/misc/effect.py
from random import uniform, random
from math import sqrt, tan, pi, sin, cos, hypot
from sys import stderr
from pygame.pixelarray import PixelArray
from sc8pr.util import rgba, style
    from pygame.surfarray import pixels_alpha
import pygame

class Squash(Wipe):

    @staticmethod
    def _apply(srf, pos, size, origSize):
        "Blit the scaled image onto a transparent background"
        srf = pygame.transform.smoothscale(srf, size)
        img = pygame.Surface(origSize, pygame.SRCALPHA)
        img.blit(srf, pos)
        return img


class MathEffect(Effect):
    "Effect based on y < f(x) or y > f(x)"

    def __init__(self, noise=0.15, fill=(0,0,0,0)):
        self.fill = rgba(fill)
        self.above = noise > 0
        self.noise = abs(noise)

    def eqn(self, x, n, size):
        dh = self.noise
        if not self.above: n = 1 - n
        return size[1] * ((1 + dh) * n - uniform(0, dh)), self.above

    def apply(self, img, n=0):
        "Modify image based on equation provided"
        if n >= 1: return img
        srf, size = self.srfSize(img, True)
        h = size[1]
        pxa = PixelArray(srf)

        x = 0