# 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
    def __init__(self, color, replace=(0,0,0,0), dist=0.0):
        self.color1 = rgba(color)
        self.color2 = rgba(replace)
        self.dist = dist

    def apply(self, img, n=0):
        if n >= 1: return img
        srf = self.srfSize(img)
        d = self.dist * (1 - n)
        pygame.PixelArray(srf).replace(self.color1, self.color2, d)
        return img


class Style(Effect):
    "Add a border or background (non-animated)"
    
    def __init__(self, **kwargs):
        if "padding" in kwargs: # Alters blit rect!
            raise NotImplementedError("Keyword 'padding' is not permitted")
        self.kwargs = kwargs
    
    def apply(self, img, n=0):
        if not isinstance(img, pygame.Surface): img = img.image
        return style(img, **self.kwargs)


class Tint(Effect):
    "Adjust the color and/or transparency"

    def __init__(self, color=(255,255,255,0)):

# 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

    def __init__(self, color, replace=(0,0,0,0), dist=0.0):
        self.color1 = rgba(color)
        self.color2 = rgba(replace)
        self.dist = dist

    def apply(self, img, n=0):
        if n >= 1: return img
        srf = self.srfSize(img)
        d = self.dist * (1 - n)
        pygame.PixelArray(srf).replace(self.color1, self.color2, d)
        return img


class Style(Effect):
    "Add a border or background (non-animated)"
    
    def __init__(self, **kwargs):
        if "padding" in kwargs: # Alters blit rect!
            raise NotImplementedError("Keyword 'padding' is not permitted")
        self.kwargs = kwargs
    
    def apply(self, img, n=0):
        if not isinstance(img, pygame.Surface): img = img.image
        return style(img, **self.kwargs)


class Tint(Effect):
    "Adjust the color and/or transparency"

    def __init__(self, color=(255,255,255,0)):

        self.color = rgba(color)