aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <s@jaseg.de>2013-04-06 13:18:42 +0200
committerjaseg <s@jaseg.de>2013-04-06 13:18:42 +0200
commit938d6298e294d3b711195858290de73fdfea317e (patch)
treef8c6524ce3e6f6cd92f2706fc4a08ad4fcbcecf2
parente05209b92a247ced88584ef7a395046398328752 (diff)
downloadpixelterm-938d6298e294d3b711195858290de73fdfea317e.tar.gz
pixelterm-938d6298e294d3b711195858290de73fdfea317e.tar.bz2
pixelterm-938d6298e294d3b711195858290de73fdfea317e.zip
Fixed rendering of the last line
-rwxr-xr-xpixelterm.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/pixelterm.py b/pixelterm.py
index 74e003f..4dbcee0 100755
--- a/pixelterm.py
+++ b/pixelterm.py
@@ -38,7 +38,7 @@ def termify_pixels(img):
r,g,b,_ = color
fgd[color]= terminal256.EscapeSequence(fg=formatter._closest_color(r,g,b)).color_string()
return fgd[color]
- #NOTE: This ignores the last line if there is an odd number of lines.
+
def balloon(x,y):
if img.getpixel((x+1, y)) != (0,255,0,127):
w = 1
@@ -49,10 +49,10 @@ def termify_pixels(img):
return '$balloon{}$'.format(w)
return ''
- for y in range(0, sy-1, 2):
+ for y in range(0, sy+1, 2):
for x in range(sx):
coltop = img.getpixel((x, y))
- colbot = img.getpixel((x, y+1))
+ colbot = img.getpixel((x, y+1)) if y+1 < img.size[1] else (0,0,0,0)
if coltop[3] == 127: #Control colors
out += reset_sequence
@@ -76,8 +76,7 @@ def termify_pixels(img):
c,te,be = cf,te,te
out += te(coltop) + be(colbot) + c
out = out.rstrip() + '\n'
- out += reset_sequence
- return out
+ return out[:-1] + reset_sequence
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Render pixel images on 256-color ANSI terminals')