Update s273.pyde

main
Alexandre B A Villares 2018-09-29 15:48:59 -03:00 zatwierdzone przez GitHub
rodzic 8a8d269207
commit 5cb109fe9b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 9 dodań i 10 usunięć

Wyświetl plik

@ -4,21 +4,18 @@ def setup():
global gliphs, tally
size(100, 200)
noSmooth() # turns off antialiasing
fill(0)
textSize(100)
textAlign(CENTER, CENTER)
printable_ascii = list(range(32, 127)) + list(range(161, 256))
for c in printable_ascii:
gliph = chr(c)
background(255)
text(gliph, width/2, height/2)
tally = count_pixels()
b, w, o = count_pixels()
print("{}({}) black: {} white: {} other: {}"
.format(c, gliph, *tally))
b, w, o = tally
table.append((c, b, w, o))
.format(c, gliph, b, w, o))
table.append((gliph, b, w, o))
table.sort(key=lambda s: s[1])
gliphs = "".join([chr(c) for c, b, w, o in table])
gliphs = "".join([gliph for gliph, b, w, o in table])
print(gliphs)
def count_pixels():
@ -36,8 +33,10 @@ def count_pixels():
def draw():
background(255)
fill(0)
i = int(map(mouseY, 0, height-1, 0, len(gliphs)-1))
textSize(100)
text(gliphs[i], width/2, height/2)
gliph, b, w, o = table[i]
textSize(8)
text(str(table[i]), width/2, 20)
text("B:{}\nW:{}:\nO:{}".format(b, w, o), width/2, 20)
textSize(100)
text(gliph, width/2, height/2)