# caracteres.py

Created by schraf

Created on September 21, 2022

1.06 KB

Explications en vidéo

Autre exemple

Des idées de caractères : Symbolïzm / Rune / Gumi

```import turtle
from kandinsky import fill_rect
from time import sleep

tt = turtle
tt.hideturtle()
tt.speed(0)

az=['@Nv?OrZEcElEdtcw@Kd?Odkama', '@MU?NFeAhLh\\UdP_OXiXidhp[wLt@ZD?ZGOsNw',
'@PN?PNgNgN@XN?XPXVXVXVRXSaSjVo]odofgfbf\\dW`U`S`N`N@S[?S[e[e[']

def move(x,y):tt.goto(x-160,110-y)

def coord(a,b,c,d,t):
return a*(1-t)**3+3*b*t*(1-t)**2+3*c*t*t*(1-t)+d*t**3

def bezier(x,y,l,cc):
tt.pendown()
t=0
for i in range(11):
u=coord(l[0],l[2],l[4],l[6],t)
v=coord(l[1],l[3],l[5],l[7],t)
move(x+cc*u,y+cc*v)
t+=.1

def f(l):return [ord(c) - 65 for c in l]

def lettre(x,y,svg,cc):
i = 0
while i<len(svg):
if svg[i]=="@":
l=[svg[i+1],svg[i+2]]
tt.penup()
move(x+cc*f(l)[0],y+cc*f(l)[1])
i+=3
elif svg[i]=="?":i+=1
else:
for j in range(6):l.append(svg[i+j])
bezier(x,y,f(l),cc)
l=[svg[i+4],svg[i+5]]
i+=6

def phrase(x,y,txt,cc=1,ps=1):
tt.pensize(ps)
for i,c in enumerate(txt):
if c!=" ":
lettre(x+cc*(40*i),y,az[ord(c)-97],cc)

phrase(15,10,"abc")
phrase(30,100,"c",2,2)
phrase(120,-10,"a",4,4)```