wtf.py

Created by schraf

Created on October 21, 2022

1.44 KB


import turtle
from kandinsky import fill_rect
from time import sleep

fill_rect(0,0,320,222,(40,60,30))
tt = turtle
tt.hideturtle()
tt.speed(0)
tt.color((255,)*3)

az=['@FN?GRNqPrUl^[^Xa_fliooiuSuL', '@MS?URoMsN@`Q?`U\\k^n', '@XM?WTUlTp@XM?\\LmKmK@W`?Z`h]j]', '@ZO?_GkHkRk\\[\\\\f@[n?WmWqXqXrZs\\r]q^o]o']

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)
 tt.penup()
 sleep(.6)

def cercle(r):
  tt.pensize(1)
  tt.setheading(90)
  tt.pendown()
  tt.circle(r)
  tt.penup()

tt.penup()
tt.goto(70,35)
cercle(75)
phrase(125,10,"a",ps=2)
tt.goto(20,-35)
cercle(75)
phrase(45,140,"b",ps=2)
phrase(90,85,"ab",.4,ps=1)
tt.goto(120,-35)
cercle(75)
phrase(210,140,"c",ps=2)
phrase(185,85,"ac",.4,ps=1)
phrase(135,160,"bc",.4,ps=1)
tt.color((255,255,0))
phrase(130,100,"d",.8,ps=3)

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.