Example #1
0
 def convert(self):
     """Yields xterm color codes for each pixel in image
     """
     (width, height) = self.img.size
     bgcolor = utils.term.bgcolor
     self.img.load()
     for y in range(height):
         for x in range(width):
             rgba = self.img.getpixel((x, y))
             if len(rgba) == 4 and rgba[3] == 0:
                 yield None
             elif len(rgba) == 3 or rgba[3] == 255:
                 yield xterm256.rgb_to_xterm(*rgba[:3])
             else:
                 color = gf.Color.NewFromRgb(*[c / 255.0 for c in rgba])
                 rgba = gf.Color.AlphaBlend(color, bgcolor).rgb
                 yield xterm256.rgb_to_xterm(
                     *[int(c * 255.0) for c in rgba])
         yield "EOL"
Example #2
0
 def convert(self):
     """Yields xterm color codes for each pixel in image
     """
     (width, height) = self.img.size
     bgcolor = utils.term.bgcolor
     self.img.load()
     for y in range(height):
         for x in range(width):
             rgba = self.img.getpixel((x, y))
             if len(rgba) == 4 and rgba[3] == 0:
                 yield None
             elif len(rgba) == 3 or rgba[3] == 255:
                 yield xterm256.rgb_to_xterm(*rgba[:3])
             else:
                 color = gf.Color.NewFromRgb(*[c / 255.0 for c in rgba])
                 rgba = gf.Color.AlphaBlend(color, bgcolor).rgb
                 yield xterm256.rgb_to_xterm(
                     *[int(c * 255.0) for c in rgba])
         yield "EOL"
Example #3
0
 def __init__(self, color, *items):
     self.bg = xterm256.rgb_to_xterm(*parse_color(color))
     self.fg = xterm256.rgb_to_xterm(*complement(color))
     self.items = items
Example #4
0
 def __init__(self, color, *items):
     (r, g, b) = parse_color(color)
     self.color = xterm256.rgb_to_xterm(r, g, b)
     self.items = items
Example #5
0
 def __init__(self, color, *items):
     (r, g, b) = parse_color(color)
     self.color = xterm256.rgb_to_xterm(r, g, b)
     self.items = items
Example #6
0
 def __init__(self, color, *items):
     self.bg = xterm256.rgb_to_xterm(*parse_color(color))
     self.fg = xterm256.rgb_to_xterm(*complement(color))
     self.items = items
Example #7
0
def html2xterm256(color):
    r, g, b = Color.HtmlToRgb(html_color)
    r = int(r * 255)
    g = int(g * 255)
    b = int(b * 255)
    return rgb_to_xterm(r, g, b)
Example #8
0
def fg_start(color):
        return esc(38, 5, xterm256.rgb_to_xterm(*parse_color(color)))