En cours de réalisation : création de code-barres “Code 39” https://fr.wikipedia.org/wiki/Code_39
from kandinsky import * def rect(x, l): for i in range(l*200): set_pixel(x+i%l,i//l,0) def c39(txt): code = {'A':265,'B':73,'C':328,'D':25,'E':280,'F':88,'G':13,'H':268,'I':76,'J':28,'K':259,'L':67,'M':322,'N':19,'O':274,'P':82,'Q':7,'R':262,'S':70,'T':22,'U':385,'V':193,'W':448,'X':145,'Y':400,'Z':208,'0':52,'1':289,'2':97,'3':352,'4':49,'5':304,'6':112,'7':37,'8':292,'9':100,' ':196,'-':133,'$':168,'%':42,'.':388,'/':162,'+':138,'*':148} traits = "" final = "" for c in "*"+txt.upper()+"*": if c in code: #traits += ("0"*9+bin(code[c])[2:])[-9:] #traits += bin(code[c])[2:].zfill(9) traits += '{:09b}'.format(code[c]) final += c pos = 0 for i,v in enumerate(traits): if i%9==0: pos+=2 if v=="1": if (i%9)%2==0:rect(pos,4) pos+=4 else: if (i%9)%2==0:rect(pos,2) pos+=2 draw_string(final,10,202) print(c39("numworks19"))