alphabet.py

Created by cent20

Created on September 21, 2022

506 Bytes

alphabet by schraf à modifier https://my.numworks.com/python/schraf/alphabet


from kandinsky import *

BL,WH,GR,RE = (0,0,0),(248,252,248),(230,)*3,(255,0,0)

def dot(x,y,c,fg,bg,t,a,b):
  draw_string(c,0,0,GR,WH)
  fill_rect(x,y,9*t,18*t,bg)
  for v in range(18):
    for u in range(9):
      if get_pixel(u,v)!=WH:
        fill_rect(x+u*t,y+v*t,t-a,t-b,fg)
  draw_string(" ",0,0,WH,WH)        

def aff(txt,x,y,t,fg,bg=WH,a=1,b=1):
  for (i,c) in enumerate(txt):
    dot(x+i*t*9,y,c,fg,bg,t,a,b)

# Exemples
aff('ABCDEF',20,0,2,BL,WH)
aff('0123456789',20,50,2,BL,WH)