# Path: fabulous/text.py
# class Text(image.Image):
# class FontNotFound(ValueError):
#     def __init__(self, text, fsize=23, color="#0099ff", shadow=False,
#                  skew=None, font='NotoSans-Bold'):
# def resolve_font(name):
# def get_font_files():
# def main():
# 
# Path: fabulous/utils.py
# def memoize(function):
#     def _memoize(*args):
#     def __init__(self, bgcolor='black'):
#     def termfd(self):
#     def dimensions(self):
#     def width(self):
#     def height(self):
#     def _get_bgcolor(self):
#     def _set_bgcolor(self, color):
# def pil_check():
# class TerminalInfo(object):
# 
# Path: fabulous/image.py
# class Image(object):
#     def __init__(self, path, width=None):
#     def __iter__(self):
#     def __str__(self):
#     def size(self):
#     def resize(self, width=None):
#     def reduce(self, colors):
#     def convert(self):
# def main():
# 
# Path: fabulous/debug.py
# class DebugImage(image.Image):
#     def reduce(self, colors):
# def main():
# 
# Path: fabulous/xterm256.py
# CUBE_STEPS = [0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF]
# BASIC16 = ((0, 0, 0), (205, 0, 0), (0, 205, 0), (205, 205, 0),
#            (0, 0, 238), (205, 0, 205), (0, 205, 205), (229, 229, 229),
#            (127, 127, 127), (255, 0, 0), (0, 255, 0), (255, 255, 0),
#            (92, 92, 255), (255, 0, 255), (0, 255, 255), (255, 255, 255))
# COLOR_TABLE = [xterm_to_rgb(i) for i in range(256)]
# def xterm_to_rgb(xcolor):
# def rgb_to_xterm(r, g, b):
# def compile_speedup():
#     def xterm_to_rgb(xcolor):
# 
# Path: fabulous/compatibility.py
# def printy(s):
#     """Python 2/3 compatible print-like function"""
#     if hasattr(s, 'as_utf8'):
#         if hasattr(sys.stdout, 'buffer'):
#             sys.stdout.buffer.write(s.as_utf8)
#             sys.stdout.buffer.write(b"\n")
#         else:
#             sys.stdout.write(s.as_utf8)
#             sys.stdout.write(b"\n")
#     else:
#         print(s)


import os
import fabulous
        import urllib
from fabulous import text, utils, image, debug, xterm256
from fabulous.color import *
from fabulous.compatibility import printy
    printy("")


def demo_image():
    section("Semi-Transparent PNG")
    imp = "  from fabulous import image\n  "
    printy(bold(imp + 'print image.Image("balls.png")\n'))

    balls = 'balls.png'
    fabdir = os.path.dirname(fabulous.__file__)

    for fn in ['balls.png',
               'fabulous/balls.png',
               os.path.join(fabdir, 'balls.png')]:
        if os.path.exists(fn):
            balls = fn
            break

    if not os.path.exists(balls):
        ugh = urllib.urlopen('http://lobstertech.com/media/img/balls.png')
        open('balls.png', 'w').write(ugh.read())
        balls = 'balls.png'

    for line in image.Image(balls):
        printy(line)
    wait()

    section("Yes the output is optimized (JELLY-FISH)")
    imp = "  from fabulous import debug\n  "
    printy(bold(imp + 'print debug.DebugImage("balls.png")\n'))

# Path: fabulous/text.py
# class Text(image.Image):
# class FontNotFound(ValueError):
#     def __init__(self, text, fsize=23, color="#0099ff", shadow=False,
#                  skew=None, font='NotoSans-Bold'):
# def resolve_font(name):
# def get_font_files():
# def main():
# 
# Path: fabulous/utils.py
# def memoize(function):
#     def _memoize(*args):
#     def __init__(self, bgcolor='black'):
#     def termfd(self):
#     def dimensions(self):
#     def width(self):
#     def height(self):
#     def _get_bgcolor(self):
#     def _set_bgcolor(self, color):
# def pil_check():
# class TerminalInfo(object):
# 
# Path: fabulous/image.py
# class Image(object):
#     def __init__(self, path, width=None):
#     def __iter__(self):
#     def __str__(self):
#     def size(self):
#     def resize(self, width=None):
#     def reduce(self, colors):
#     def convert(self):
# def main():
# 
# Path: fabulous/debug.py
# class DebugImage(image.Image):
#     def reduce(self, colors):
# def main():
# 
# Path: fabulous/xterm256.py
# CUBE_STEPS = [0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF]
# BASIC16 = ((0, 0, 0), (205, 0, 0), (0, 205, 0), (205, 205, 0),
#            (0, 0, 238), (205, 0, 205), (0, 205, 205), (229, 229, 229),
#            (127, 127, 127), (255, 0, 0), (0, 255, 0), (255, 255, 0),
#            (92, 92, 255), (255, 0, 255), (0, 255, 255), (255, 255, 255))
# COLOR_TABLE = [xterm_to_rgb(i) for i in range(256)]
# def xterm_to_rgb(xcolor):
# def rgb_to_xterm(r, g, b):
# def compile_speedup():
#     def xterm_to_rgb(xcolor):
# 
# Path: fabulous/compatibility.py
# def printy(s):
#     """Python 2/3 compatible print-like function"""
#     if hasattr(s, 'as_utf8'):
#         if hasattr(sys.stdout, 'buffer'):
#             sys.stdout.buffer.write(s.as_utf8)
#             sys.stdout.buffer.write(b"\n")
#         else:
#             sys.stdout.write(s.as_utf8)
#             sys.stdout.write(b"\n")
#     else:
#         print(s)


# Path: fabulous/demo.py
import os
import fabulous
        import urllib
from fabulous import text, utils, image, debug, xterm256
from fabulous.color import *
from fabulous.compatibility import printy

    printy("")


def demo_image():
    section("Semi-Transparent PNG")
    imp = "  from fabulous import image\n  "
    printy(bold(imp + 'print image.Image("balls.png")\n'))

    balls = 'balls.png'
    fabdir = os.path.dirname(fabulous.__file__)

    for fn in ['balls.png',
               'fabulous/balls.png',
               os.path.join(fabdir, 'balls.png')]:
        if os.path.exists(fn):
            balls = fn
            break

    if not os.path.exists(balls):
        ugh = urllib.urlopen('http://lobstertech.com/media/img/balls.png')
        open('balls.png', 'w').write(ugh.read())
        balls = 'balls.png'

    for line in image.Image(balls):
        printy(line)
    wait()

    section("Yes the output is optimized (JELLY-FISH)")
    imp = "  from fabulous import debug\n  "
    printy(bold(imp + 'print debug.DebugImage("balls.png")\n'))

    for line in debug.DebugImage(balls):