# Path: luma/core/mixin.py
# class capabilities(object):
#     def capabilities(self, width, height, rotate, mode="1"):
#     def clear(self):
#     def preprocess(self, image):
#     def display(self, image):
# 
# Path: luma/core/ansi_color.py
# def parse_str(text):
# def strip_ansi_codes(text):
# def find_directives(text, klass):
# 
# Path: luma/core/threadpool.py
# class threadpool:
#     """
#     Pool of threads consuming tasks from a queue.
#     """
#     def __init__(self, num_threads):
#         try:
#             from Queue import Queue
#         except ImportError:
#             from queue import Queue
# 
#         self.tasks = Queue(num_threads)
#         for _ in range(num_threads):
#             worker(self.tasks)
# 
#     def add_task(self, func, *args, **kargs):
#         """
#         Add a task to the queue.
#         """
#         self.tasks.put((func, args, kargs))
# 
#     def wait_completion(self):
#         """
#         Wait for completion of all the tasks in the queue.
#         """
#         self.tasks.join()
# 
# Path: luma/core/render.py
# class canvas(object):
#     """
#     A canvas returns a properly-sized :py:mod:`PIL.ImageDraw` object onto
#     which the caller can draw upon. As soon as the with-block completes, the
#     resultant image is flushed onto the device.
# 
#     By default, any color (other than black) will be `generally` treated as
#     white when displayed on monochrome devices. However, this behaviour can be
#     changed by adding ``dither=True`` and the image will be converted from RGB
#     space into a 1-bit monochrome image where dithering is employed to
#     differentiate colors at the expense of resolution.
#     If a ``background`` parameter is provided, the canvas is based on the given
#     background. This is useful to e.g. write text on a given background image.
#     """
#     def __init__(self, device, background=None, dither=False):
#         self.draw = None
#         if background is None:
#             self.image = Image.new("RGB" if dither else device.mode, device.size)
#         else:
#             assert(background.size == device.size)
#             self.image = background.copy()
#         self.device = device
#         self.dither = dither
# 
#     def __enter__(self):
#         self.draw = ImageDraw.Draw(self.image)
#         return self.draw
# 
#     def __exit__(self, type, value, traceback):
#         if type is None:
# 
#             if self.dither:
#                 self.image = self.image.convert(self.device.mode)
# 
#             # do the drawing onto the device
#             self.device.display(self.image)
# 
#         del self.draw   # Tidy up the resources
#         return False    # Never suppress exceptions
# 
# Path: luma/core/util.py
# class mutable_string(object):
# 
#     def __init__(self, value):
#         assert isinstance(value, str) or isinstance(value, unicode)
#         self.target = value
# 
#     def __getattr__(self, attr):
#         return self.target.__getattribute__(attr)
# 
#     def __getitem__(self, key):
#         return self.target[key]
# 
#     def __setitem__(self, key, value):
#         assert isinstance(value, str) or isinstance(value, unicode)
#         tmp = list(self.target)
#         tmp[key] = value
#         self.target = ("" if isinstance(self.target, str) else u"").join(tmp)
# 
#     def __delitem__(self, key):
#         tmp = list(self.target)
#         del tmp[key]
#         self.target = "".join(tmp)
# 
#     def __len__(self):
#         return len(self.target)
# 
#     def __iter__(self):
#         return iter(self.target)
# 
#     def __str__(self):
#         return self.target
# 
#     def __repr__(self):
#         return repr(self.target)
# 
#     def __eq__(self, other):
#         if isinstance(self.target, unicode):
#             return self.target == unicode(other)
#         else:
#             return self.target == str(other)
# 
#     def __hash__(self):
#         return hash(self.target)
# 
# class observable(object):
#     """
#     Wraps any container object such that on inserting, updating or deleting,
#     an observer is notified with a payload of the target. All other special
#     name methods are passed through parameters unhindered.
#     """
#     def __init__(self, target, observer):
#         self.target = target
#         self.observer = observer
#         self.observer(self.target)
# 
#     def __getattr__(self, attr):
#         return self.target.__getattribute__(attr)
# 
#     def __getitem__(self, key):
#         return self.target.__getitem__(key)
# 
#     def __setitem__(self, key, value):
#         self.target.__setitem__(key, value)
#         self.observer(self.target)
# 
#     def __delitem__(self, key):
#         self.target.__delitem__(key)
#         self.observer(self.target)
# 
#     def __len__(self):
#         return self.target.__len__()
# 
#     def __iter__(self):
#         return self.target.__iter__()
# 
#     def __str__(self):
#         return self.target.__str__()
# 
#     def __repr__(self):
#         return self.target.__repr__()


from textwrap import TextWrapper
from time import sleep, perf_counter
from PIL import Image, ImageDraw, ImageFont
from luma.core import mixin, ansi_color
from luma.core.threadpool import threadpool
from luma.core.render import canvas
from luma.core.util import mutable_string, observable

        :param value: The new color value, either string name or RGB tuple.
        :type value: str or tuple
        """
        self._fgcolor = value

    def background_color(self, value):
        """
        Sets the background color.

        :param value: The new color value, either string name or RGB tuple.
        :type value: str or tuple
        """
        self._bgcolor = value

    def reset(self):
        """
        Resets the foreground and background color value back to the original
        when initialised.
        """
        self._fgcolor = self.default_fgcolor
        self._bgcolor = self.default_bgcolor

    def reverse_colors(self):
        """
        Flips the foreground and background colors.
        """
        self._bgcolor, self._fgcolor = self._fgcolor, self._bgcolor



# Path: luma/core/mixin.py
# class capabilities(object):
#     def capabilities(self, width, height, rotate, mode="1"):
#     def clear(self):
#     def preprocess(self, image):
#     def display(self, image):
# 
# Path: luma/core/ansi_color.py
# def parse_str(text):
# def strip_ansi_codes(text):
# def find_directives(text, klass):
# 
# Path: luma/core/threadpool.py
# class threadpool:
#     """
#     Pool of threads consuming tasks from a queue.
#     """
#     def __init__(self, num_threads):
#         try:
#             from Queue import Queue
#         except ImportError:
#             from queue import Queue
# 
#         self.tasks = Queue(num_threads)
#         for _ in range(num_threads):
#             worker(self.tasks)
# 
#     def add_task(self, func, *args, **kargs):
#         """
#         Add a task to the queue.
#         """
#         self.tasks.put((func, args, kargs))
# 
#     def wait_completion(self):
#         """
#         Wait for completion of all the tasks in the queue.
#         """
#         self.tasks.join()
# 
# Path: luma/core/render.py
# class canvas(object):
#     """
#     A canvas returns a properly-sized :py:mod:`PIL.ImageDraw` object onto
#     which the caller can draw upon. As soon as the with-block completes, the
#     resultant image is flushed onto the device.
# 
#     By default, any color (other than black) will be `generally` treated as
#     white when displayed on monochrome devices. However, this behaviour can be
#     changed by adding ``dither=True`` and the image will be converted from RGB
#     space into a 1-bit monochrome image where dithering is employed to
#     differentiate colors at the expense of resolution.
#     If a ``background`` parameter is provided, the canvas is based on the given
#     background. This is useful to e.g. write text on a given background image.
#     """
#     def __init__(self, device, background=None, dither=False):
#         self.draw = None
#         if background is None:
#             self.image = Image.new("RGB" if dither else device.mode, device.size)
#         else:
#             assert(background.size == device.size)
#             self.image = background.copy()
#         self.device = device
#         self.dither = dither
# 
#     def __enter__(self):
#         self.draw = ImageDraw.Draw(self.image)
#         return self.draw
# 
#     def __exit__(self, type, value, traceback):
#         if type is None:
# 
#             if self.dither:
#                 self.image = self.image.convert(self.device.mode)
# 
#             # do the drawing onto the device
#             self.device.display(self.image)
# 
#         del self.draw   # Tidy up the resources
#         return False    # Never suppress exceptions
# 
# Path: luma/core/util.py
# class mutable_string(object):
# 
#     def __init__(self, value):
#         assert isinstance(value, str) or isinstance(value, unicode)
#         self.target = value
# 
#     def __getattr__(self, attr):
#         return self.target.__getattribute__(attr)
# 
#     def __getitem__(self, key):
#         return self.target[key]
# 
#     def __setitem__(self, key, value):
#         assert isinstance(value, str) or isinstance(value, unicode)
#         tmp = list(self.target)
#         tmp[key] = value
#         self.target = ("" if isinstance(self.target, str) else u"").join(tmp)
# 
#     def __delitem__(self, key):
#         tmp = list(self.target)
#         del tmp[key]
#         self.target = "".join(tmp)
# 
#     def __len__(self):
#         return len(self.target)
# 
#     def __iter__(self):
#         return iter(self.target)
# 
#     def __str__(self):
#         return self.target
# 
#     def __repr__(self):
#         return repr(self.target)
# 
#     def __eq__(self, other):
#         if isinstance(self.target, unicode):
#             return self.target == unicode(other)
#         else:
#             return self.target == str(other)
# 
#     def __hash__(self):
#         return hash(self.target)
# 
# class observable(object):
#     """
#     Wraps any container object such that on inserting, updating or deleting,
#     an observer is notified with a payload of the target. All other special
#     name methods are passed through parameters unhindered.
#     """
#     def __init__(self, target, observer):
#         self.target = target
#         self.observer = observer
#         self.observer(self.target)
# 
#     def __getattr__(self, attr):
#         return self.target.__getattribute__(attr)
# 
#     def __getitem__(self, key):
#         return self.target.__getitem__(key)
# 
#     def __setitem__(self, key, value):
#         self.target.__setitem__(key, value)
#         self.observer(self.target)
# 
#     def __delitem__(self, key):
#         self.target.__delitem__(key)
#         self.observer(self.target)
# 
#     def __len__(self):
#         return self.target.__len__()
# 
#     def __iter__(self):
#         return self.target.__iter__()
# 
#     def __str__(self):
#         return self.target.__str__()
# 
#     def __repr__(self):
#         return self.target.__repr__()


# Path: luma/core/virtual.py
from textwrap import TextWrapper
from time import sleep, perf_counter
from PIL import Image, ImageDraw, ImageFont
from luma.core import mixin, ansi_color
from luma.core.threadpool import threadpool
from luma.core.render import canvas
from luma.core.util import mutable_string, observable


        :param value: The new color value, either string name or RGB tuple.
        :type value: str or tuple
        """
        self._fgcolor = value

    def background_color(self, value):
        """
        Sets the background color.

        :param value: The new color value, either string name or RGB tuple.
        :type value: str or tuple
        """
        self._bgcolor = value

    def reset(self):
        """
        Resets the foreground and background color value back to the original
        when initialised.
        """
        self._fgcolor = self.default_fgcolor
        self._bgcolor = self.default_bgcolor

    def reverse_colors(self):
        """
        Flips the foreground and background colors.
        """
        self._bgcolor, self._fgcolor = self._fgcolor, self._bgcolor



class history(mixin.capabilities):