# Path: sc8pr/geom.py
# def sigma(*args):
#     "Sum one or more vectors"
#     return tuple(sum(x[i] for x in args) for i in range(len(args[0])))
# 
# def delta(v2, v1=None, mag=None):
#     "v2 - v1, rescaled to specified magnitude"
#     if v1:
#         x = v2[0] - v1[0]
#         y = v2[1] - v1[1]
#     else: x, y = v2
#     if mag is not None:
#         r = hypot(x, y)
#         if r:
#             mag /= r
#             x *= mag
#             y *= mag
#     return x, y


import sys, pygame
from random import randint
from traceback import format_exc
from zipfile import ZipFile
from pathlib import Path
from sc8pr.geom import sigma, delta
    "Float version of built-in range function"
    while (dx > 0 and x < xEnd) or (dx < 0 and x > xEnd):
        yield x
        x += dx

def zipData(archive, *args):
    "Generator for reading zipfile data"
    with ZipFile(archive) as zf:
        for a in args: yield(zf.read(a))

def sc8prData(*args, archive=resolvePath("sc8pr.data")):
    "Read data from a zipfile"
    t = list(zipData(archive, *args))
    return t if len(args) > 1 else t[0]

def hasAlpha(srf):
    "Check if surface has per-pixel alpha"
    return srf.get_masks()[3] != 0

def setAlpha(srf, a):
    "Adjust surface with a minimum transparency "
    srf.fill((255,255,255,a), special_flags=pygame.BLEND_RGBA_MIN)
    return srf

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

# Path: sc8pr/geom.py
# def sigma(*args):
#     "Sum one or more vectors"
#     return tuple(sum(x[i] for x in args) for i in range(len(args[0])))
# 
# def delta(v2, v1=None, mag=None):
#     "v2 - v1, rescaled to specified magnitude"
#     if v1:
#         x = v2[0] - v1[0]
#         y = v2[1] - v1[1]
#     else: x, y = v2
#     if mag is not None:
#         r = hypot(x, y)
#         if r:
#             mag /= r
#             x *= mag
#             y *= mag
#     return x, y


# Path: sc8pr/util.py
import sys, pygame
from random import randint
from traceback import format_exc
from zipfile import ZipFile
from pathlib import Path
from sc8pr.geom import sigma, delta

    "Float version of built-in range function"
    while (dx > 0 and x < xEnd) or (dx < 0 and x > xEnd):
        yield x
        x += dx

def zipData(archive, *args):
    "Generator for reading zipfile data"
    with ZipFile(archive) as zf:
        for a in args: yield(zf.read(a))

def sc8prData(*args, archive=resolvePath("sc8pr.data")):
    "Read data from a zipfile"
    t = list(zipData(archive, *args))
    return t if len(args) > 1 else t[0]

def hasAlpha(srf):
    "Check if surface has per-pixel alpha"
    return srf.get_masks()[3] != 0

def setAlpha(srf, a):
    "Adjust surface with a minimum transparency "
    srf.fill((255,255,255,a), special_flags=pygame.BLEND_RGBA_MIN)
    return srf

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]