# 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
    @staticmethod
    def makeDrop():
        "Create random diameter, start and end time"
        t1 = uniform(0, 0.8)
        t2 = uniform(t1 + 0.1, 1)
        return [uniform(0.1, 1), min(t1, t2), max(t1, t2)]


class Dissolve(Effect):
    "Replace pixels randomly by a specified or random color"

    def __init__(self, colors=(0,0,0,0), keepTransparent=True, alpha=True):
#        if not colors: self.colors = alpha
        t = type(colors)
        if t is int:
            self.colors = [rgba(alpha) for i in range(colors)]
        elif t is bool: self.colors = colors
        else:
            if t in (str, pygame.Color) or type(colors[0]) is int:
                colors = colors,
            self.colors = [rgba(i) for i in colors]
        self.n = -1
        self.keep = keepTransparent

    def apply(self, img, n):
        "Apply pixel-by-pixel effect"
        if n >= 1: return img
        srf = self.srfSize(img)
        self.alphaMask = srf.map_rgb((0,0,0,255))
        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

    @staticmethod
    def makeDrop():
        "Create random diameter, start and end time"
        t1 = uniform(0, 0.8)
        t2 = uniform(t1 + 0.1, 1)
        return [uniform(0.1, 1), min(t1, t2), max(t1, t2)]


class Dissolve(Effect):
    "Replace pixels randomly by a specified or random color"

    def __init__(self, colors=(0,0,0,0), keepTransparent=True, alpha=True):
#        if not colors: self.colors = alpha
        t = type(colors)
        if t is int:
            self.colors = [rgba(alpha) for i in range(colors)]
        elif t is bool: self.colors = colors
        else:
            if t in (str, pygame.Color) or type(colors[0]) is int:
                colors = colors,
            self.colors = [rgba(i) for i in colors]
        self.n = -1
        self.keep = keepTransparent

    def apply(self, img, n):
        "Apply pixel-by-pixel effect"
        if n >= 1: return img
        srf = self.srfSize(img)
        self.alphaMask = srf.map_rgb((0,0,0,255))
        pxa = PixelArray(srf)

        x = 0