diff options
author | jaseg <s@jaseg.de> | 2013-04-02 02:11:48 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-04-02 02:11:48 +0200 |
commit | 8e1808e4c896956efff60410279886160c9a793c (patch) | |
tree | cfa647c2b2fd607a077aeb9b6166d1394428a937 | |
parent | 4e0849e34910feb04d30900c028f9760f5f70e47 (diff) | |
download | pixelterm-8e1808e4c896956efff60410279886160c9a793c.tar.gz pixelterm-8e1808e4c896956efff60410279886160c9a793c.tar.bz2 pixelterm-8e1808e4c896956efff60410279886160c9a793c.zip |
Working, simplified.
-rwxr-xr-x | pixelterm.py | 63 |
1 files changed, 11 insertions, 52 deletions
diff --git a/pixelterm.py b/pixelterm.py index bbf15c6..5560f32 100755 --- a/pixelterm.py +++ b/pixelterm.py @@ -18,7 +18,6 @@ def termify_pixels(img): return terminal256.EscapeSequence(fg=formatter._closest_color(r,g,b)).color_string() #NOTE: This ignores the last line if there is an odd number of lines. for y in range(0, sy-1, 2): - lastfg, lastbg = None, None for x in range(sx): coltop = img.getpixel((x, y)) colbot = img.getpixel((x, y+1)) @@ -26,57 +25,17 @@ def termify_pixels(img): coltop = (0,0,0,0) if colbot[3] != 255: colbot = (0,0,0,0) - if coltop == colbot: - if lastfg == coltop: - out += '█' - elif lastbg == coltop: - out += ' ' - else: - out += bgescape(coltop) - lastfg = coltop - out += ' ' - else: - if coltop == (0,0,0,0): - if lastfg != colbot: - out += fgescape(colbot) - lastfg = colbot - if lastbg != coltop: - out += bgescape(coltop) - lastbg = coltop - out += '▄' - elif colbot == (0,0,0,0): - if lastfg != coltop: - out += fgescape(coltop) - lastfg = coltop - if lastbg != colbot: - out += bgescape(colbot) - lastbg = colbot - out += '▀' - elif lastbg == coltop: - if lastfg != colbot: - out += fgescape(colbot) - lastfg = colbot - out += '▄' - elif lastbg == colbot: - if lastfg != coltop: - out += fgescape(coltop) - lastfg = coltop - out += '▀' - else: - if lastfg == coltop: - out += bgescape(coltop) - lastbg = coltop - out += '▀' - elif lastfg == colbot: - out += bgescape(colbot) - lastbg = colbot - out += '▄' - else: - out += fgescape(coltop) - lastfg = coltop - out += bgescape(colbot) - lastbg = colbot - out += '▀' + c = '▀' + te = fgescape + be = bgescape + #Da magicks: ▀█▄ + if coltop == (0,0,0,0): + c,te,be = '▄',be,te + if colbot == coltop: + c = ' ' + out += te(coltop) + out += be(colbot) + out += c out += '\n' return out |