# Path: opc/utils/prof.py
# def timefunc(f, reference=False):
#     global records
# 
#     records[f.__name__] = Record(f.__name__, reference)
# 
#     @wraps(f)
#     def f_timer(*args, **kwargs):
#         global active
# 
#         if not active:
#             return f(*args, **kwargs)
# 
#         start = time.time()
#         result = f(*args, **kwargs)
#         end = time.time()
# 
#         records[f.__name__].addTime(end-start)
# 
#         return result
# 
#     return f_timer


from PIL import Image, ImageFilter
from .colors import BLACK
from .utils.prof import timefunc
import numpy as np
    """
    Provdes primitive buffer-level storage and operations.
    """

    @timefunc
    def __init__(self, width, height, color=BLACK):
        self.width = width
        self.height = height
        self.shape = (width, height, 3)
        self.buf = np.empty(shape=self.shape, dtype=DTYPE)
        self.clear(color)

    def _sameSize(self, other):
        return self.buf.shape == other.buf.shape

    def __len__(self):
        return len(self.buf)

    def __xor___(self, other):
        pass

    @timefunc
    def mask(self, mask):
        self.buf = self.buf.astype(dtype=DTYPE) & mask.buf.astype(dtype=DTYPE)

    @timefunc
    def reds(self):
        """ get all of the reds from the buffer """
        return self.buf[:, :, 0]


# Path: opc/utils/prof.py
# def timefunc(f, reference=False):
#     global records
# 
#     records[f.__name__] = Record(f.__name__, reference)
# 
#     @wraps(f)
#     def f_timer(*args, **kwargs):
#         global active
# 
#         if not active:
#             return f(*args, **kwargs)
# 
#         start = time.time()
#         result = f(*args, **kwargs)
#         end = time.time()
# 
#         records[f.__name__].addTime(end-start)
# 
#         return result
# 
#     return f_timer


# Path: opc/buffer.py
from PIL import Image, ImageFilter
from .colors import BLACK
from .utils.prof import timefunc
import numpy as np

    """
    Provdes primitive buffer-level storage and operations.
    """

    @timefunc
    def __init__(self, width, height, color=BLACK):
        self.width = width
        self.height = height
        self.shape = (width, height, 3)
        self.buf = np.empty(shape=self.shape, dtype=DTYPE)
        self.clear(color)

    def _sameSize(self, other):
        return self.buf.shape == other.buf.shape

    def __len__(self):
        return len(self.buf)

    def __xor___(self, other):
        pass

    @timefunc
    def mask(self, mask):
        self.buf = self.buf.astype(dtype=DTYPE) & mask.buf.astype(dtype=DTYPE)

    @timefunc
    def reds(self):
        """ get all of the reds from the buffer """
        return self.buf[:, :, 0]


    @timefunc