alphabet.py

Created by cent20

Created on December 12, 2024

563 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)
BL,WH,GR,RE = (0,0,0),(255,255,255),(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)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.