Compare commits

..

No commits in common. "main" and "863cc599e45bbeed0d40d141b6f1dd51861ee50b" have entirely different histories.

2 changed files with 126 additions and 125 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
"""'exec /usr/bin/env python3 -u "$0" "$@" #"""
__doc__ = "little script to make irc color art that will probably get you banned"
''''exec /usr/bin/env python3 -u "$0" "$@" #'''
__doc__ = 'little script to make irc color art that will probably get you banned'
# whee, look at this sus shebang workaround to always cause
# unbuffered mode lol
@ -10,7 +10,7 @@ from color import closestColor
def main(imgPath,delay,ASCIIWIDTH,COLORCHAR,FILLER,SHARPNESS):
im = Image.open(imgPath, "r")
im = Image.open(imgPath, 'r')
im = ImageOps.scale(im, ASCIIWIDTH*SHARPNESS / im.width)
width, height = im.size
pixel_values = list(im.getdata())
@ -24,14 +24,14 @@ def main(imgPath, delay, ASCIIWIDTH, COLORCHAR, FILLER, SHARPNESS):
for x in range(0, width, SHARPNESS):
color = closestColor(pixel_values[width*y+x])
if color == lastColor:
colorcode = ""
colorcode = ''
else:
colorcode =COLORCHAR.format(color, color)
line.append(colorcode+(FILLER[currentPixel % len(FILLER)]))
lastColor=color
currentPixel+=1
print("".join(line))
print(''.join(line))
if delay:
time.sleep(delay)
@ -39,18 +39,18 @@ def main(imgPath, delay, ASCIIWIDTH, COLORCHAR, FILLER, SHARPNESS):
if __name__ == "__main__":
parser = argparse.ArgumentParser("banter")
parser.add_argument("file")
parser.add_argument("-d", metavar="delay", default=0)
parser.add_argument("-w", metavar="width", default=80)
parser.add_argument("-s", metavar="sharpness", default=4)
parser.add_argument("--colorfmt", metavar="format", default="\\x03{},{}")
parser.add_argument("--filler", metavar="filler", default=".")
parser.add_argument("-d",metavar='delay',default=0)
parser.add_argument("-w",metavar='width',default=80)
parser.add_argument("-s",metavar='sharpness',default=4)
parser.add_argument("--colorfmt",metavar='format',default='\\x03{},{}')
parser.add_argument("--filler",metavar='filler',default='.')
args = parser.parse_args()
main(
args.file,
float(args.d),
int(args.w),
args.colorfmt.encode().decode("unicode_escape"),
args.filler.encode().decode("unicode_escape"),
int(args.s),
args.colorfmt.encode().decode('unicode_escape'),
args.filler.encode().decode('unicode_escape'),
int(args.s)
)

View file

@ -93,7 +93,7 @@ MIRCCOLORS = {
12: (0,0,252),
13: (255,0,255),
14: (127,127,127),
15: (210, 210, 210),
15: (210,210,210)
}
@ -104,7 +104,7 @@ for i in MIRCCOLORS:
colors[i]=MIRCCOLORS[i]
for i in EXTENDEDCOLORS:
hex = EXTENDEDCOLORS[i].lstrip("#")
hex=EXTENDEDCOLORS[i].lstrip('#')
# https://stackoverflow.com/a/29643643/9406294
rgb=tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))
@ -127,3 +127,4 @@ def closestColor(rgb):
distance = abs(r-rc) + abs(g-gc) + abs(b-bc)
diss[cc] = distance
return min(diss, key=diss.get)