aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <s@jaseg.de>2013-04-06 17:54:31 +0200
committerjaseg <s@jaseg.de>2013-04-06 18:05:42 +0200
commit050fdb036d3a0434b5d2cb623c8874d56a9ecebb (patch)
tree95aed8f22adc50d62673a6d37acec176d1df8942
parent44216123b4b6ead42196339b09441db045547031 (diff)
downloadpixelterm-050fdb036d3a0434b5d2cb623c8874d56a9ecebb.tar.gz
pixelterm-050fdb036d3a0434b5d2cb623c8874d56a9ecebb.tar.bz2
pixelterm-050fdb036d3a0434b5d2cb623c8874d56a9ecebb.zip
Bug fixes in pixelterm
-rwxr-xr-xpixelterm.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/pixelterm.py b/pixelterm.py
index 316e674..fbaea9a 100755
--- a/pixelterm.py
+++ b/pixelterm.py
@@ -40,16 +40,14 @@ def termify_pixels(img):
return fgd[color]
def balloon(x,y):
- if img.getpixel((x+1, y)) != (0,255,0,127):
- w = 1
- while img.getpixel((x-w, y)) == (0,255,0,127):
+ if x+1 == img.size[0] or img.getpixel((x+1, y)) != (0,255,0,127):
+ w = 0
+ while x-w >= 0 and img.getpixel((x-w, y)) == (0,255,0,127):
w += 1
- if x-w<0:
- break
- return '$balloon{}$'.format(w)
+ return '$balloon{}$'.format(w+1)
return ''
- for y in range(0, sy+1, 2):
+ for y in range(0, sy, 2):
for x in range(sx):
coltop = img.getpixel((x, y))
colbot = img.getpixel((x, y+1)) if y+1 < img.size[1] else (0,0,0,0)
@@ -76,7 +74,7 @@ def termify_pixels(img):
c,te,be = cf,te,te
out += te(coltop) + be(colbot) + c
out = out.rstrip() + '\n'
- return out[:-1] + reset_sequence
+ return out[:-1] + reset_sequence + '\n'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Render pixel images on 256-color ANSI terminals')
@@ -86,6 +84,7 @@ if __name__ == '__main__':
for f in args.image:
img = Image.open(f).convert("RGBA")
if args.output_dir:
+ print(f)
foo, _, _ = f.rpartition('.png')
output = os.path.join(args.output_dir, os.path.basename(foo)+'.pony')
with open(output, 'w') as of: