font to nodered
This commit is contained in:
parent
a18bb948ec
commit
c3564ef7d2
|
@ -7,22 +7,46 @@ done = False
|
|||
|
||||
persistance=False
|
||||
fps=10
|
||||
color_checkerboardA=(250,250,250)
|
||||
color_checkerboardB=(200,200,200)
|
||||
color_bg=(255,255,255)
|
||||
color_text=(0,0,0)
|
||||
|
||||
pixelsize=8
|
||||
exportImages=True
|
||||
exportImageFolder="imageexport/"
|
||||
|
||||
pixelsize=32
|
||||
|
||||
|
||||
if exportImages:
|
||||
pixelsize=1
|
||||
color_checkerboardA=(0,0,0)
|
||||
color_checkerboardB=(0,0,0)
|
||||
color_bg=(0,0,0)
|
||||
color_text=(255,255,255)
|
||||
|
||||
#fontname="font_normal"
|
||||
#font = pygame.font.Font("Minecraftia-Regular.ttf", fontsize*pixelsize);
|
||||
#fontsize=8
|
||||
#pixelsW=6
|
||||
#pixelsH=8
|
||||
#pixelsH=8KeyboardInterrupt
|
||||
|
||||
#offset=(0,0)
|
||||
|
||||
fontname="font_large"
|
||||
fontsize=16
|
||||
pixelsW=9
|
||||
pixelsH=8*2
|
||||
offset=(0,8)
|
||||
font = pygame.font.Font("Sweet16mono.ttf", fontsize*pixelsize); # https://github.com/kmar/Sweet16Font
|
||||
#fontname="font_large"
|
||||
#fontsize=16
|
||||
#pixelsW=9
|
||||
#pixelsH=8*2
|
||||
#offset=(0,1)
|
||||
#font = pygame.font.Font("Sweet16mono.ttf", fontsize*pixelsize); # https://github.com/kmar/Sweet16Font
|
||||
|
||||
|
||||
fontname="font_small"
|
||||
fontsize=10
|
||||
pixelsW=3
|
||||
pixelsH=8
|
||||
offset=(0,2)
|
||||
font = pygame.font.Font("pzim3x5.ttf", fontsize*pixelsize); # https://www.fonts4free.net/pixelzim-3x5-font.html
|
||||
|
||||
|
||||
|
||||
|
@ -33,6 +57,8 @@ ascii = asciioffset
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
file = open("output.txt", "w") # write mode
|
||||
|
||||
|
||||
|
@ -42,7 +68,7 @@ file.write("const uint8_t "+fontname+"_offset="+str(asciioffset)+";\n");
|
|||
#file.write("uint8_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"];\n")
|
||||
file.write("const uint"+str(pixelsH)+"_t "+fontname+"["+str(asciiend-asciioffset+1)+"]["+str(pixelsW)+"]= {\n")
|
||||
|
||||
screen.fill((255, 255, 255))
|
||||
screen.fill(color_bg)
|
||||
|
||||
screencleared=False
|
||||
|
||||
|
@ -56,17 +82,17 @@ while not done:
|
|||
|
||||
if not screencleared or not persistance:
|
||||
screencleared=True
|
||||
screen.fill((255, 255, 255))
|
||||
screen.fill(color_bg)
|
||||
|
||||
for y in range(pixelsH):
|
||||
for x in range(pixelsW):
|
||||
color=(250,250,250)
|
||||
color=color_checkerboardA
|
||||
if (x+y)%2==0:
|
||||
color=(200,200,200)
|
||||
color=color_checkerboardA
|
||||
pygame.draw.rect(screen, color, pygame.Rect(pixelsize*x, pixelsize*y, pixelsize, pixelsize))
|
||||
|
||||
text = font.render(chr(ascii), True, (0, 0, 0))
|
||||
screen.blit(text,(0+offset[0],-pixelsize*2+offset[1]))
|
||||
text = font.render(chr(ascii), True, color_text)
|
||||
screen.blit(text,(0+offset[0]*pixelsize,-pixelsize*2+offset[1]*pixelsize))
|
||||
print("ascii="+str(ascii)+" char="+chr(ascii))
|
||||
|
||||
'''
|
||||
|
@ -85,7 +111,7 @@ while not done:
|
|||
string8=""
|
||||
for y in range(pixelsH):
|
||||
readcolor = screen.get_at(((int)(pixelsize*x+pixelsize/2),(int)(pixelsize*y+pixelsize/2)))
|
||||
if (readcolor==(0,0,0)):
|
||||
if (readcolor==color_text):
|
||||
int8number+=pow(2,y)
|
||||
string8+='1'
|
||||
else:
|
||||
|
@ -105,12 +131,19 @@ while not done:
|
|||
|
||||
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
if exportImages:
|
||||
exportrect=pygame.Rect(0,0,pixelsW,pixelsH)
|
||||
sub = screen.subsurface(exportrect)
|
||||
pygame.image.save(sub, exportImageFolder+str(ascii)+".png")
|
||||
|
||||
clock.tick(fps)
|
||||
|
||||
|
||||
ascii+=1
|
||||
if (ascii>asciiend):
|
||||
done=True
|
||||
|
||||
pygame.display.flip()
|
||||
clock.tick(fps)
|
||||
|
||||
file.write("};")
|
||||
file.close()
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 669 B |
|
@ -0,0 +1,78 @@
|
|||
msg.payload="\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000111111000\
|
||||
0000011000000100\
|
||||
0001100000000010\
|
||||
0010000111000001\
|
||||
0100011000000001\
|
||||
0100100000000001\
|
||||
0100000000000001\
|
||||
0100000000000001\
|
||||
0100000000000001\
|
||||
0010000000000001\
|
||||
0001100000000010\
|
||||
0000011000000100\
|
||||
0000000111111000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
Binary file not shown.
After Width: | Height: | Size: 668 B |
|
@ -0,0 +1,78 @@
|
|||
msg.payload="\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000111111000\
|
||||
0000011000000100\
|
||||
0001100000000010\
|
||||
0010000111000001\
|
||||
0100011000000001\
|
||||
0100100000000001\
|
||||
0100000000000001\
|
||||
0100000000000001\
|
||||
0100000000000001\
|
||||
0010000000000001\
|
||||
0001100000000001\
|
||||
0000011000000110\
|
||||
0000000111111000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
Binary file not shown.
After Width: | Height: | Size: 667 B |
|
@ -0,0 +1,78 @@
|
|||
msg.payload="\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000111111000\
|
||||
0000011000000110\
|
||||
0001100000000001\
|
||||
0010000111000001\
|
||||
0100011000000001\
|
||||
0100100000000001\
|
||||
0100000000000001\
|
||||
0100000000000001\
|
||||
0100000000000001\
|
||||
0010000000000001\
|
||||
0001100000000010\
|
||||
0000011000000100\
|
||||
0000000111111000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
0000000000000000\
|
||||
";
|
||||
return msg;
|
|
@ -5,6 +5,6 @@ while [ $i -ne 10 ]
|
|||
do
|
||||
|
||||
echo "$i"
|
||||
python ../generate.py retrostyle_isolated/$i.png -f nodered -o $i.txt
|
||||
python ../generate.py pzim3x5/$i.png -f nodered -o $i.txt
|
||||
i=$(($i+1))
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue