ba2023.py

Created by schraf

Created on January 01, 2023

1.05 KB


from turtle import *
from kandinsky import *
from random import randint,choice
from time import sleep

fill_rect(0,0,320,222,(0,)*3)
speed(0)
hideturtle()

def T(u,a1,a2,b1,b2): return int((b2-b1)/(a2-a1)*(u-a1)+b1)

for i in range(4):
 for j in range(3):
  x,y,w=-160+80*i+randint(0,80),110-35*j-randint(0,35),randint(0,250)
  a=0
  for u in range(54):
    penup()
    goto(x,y)
    fd(u//18*10)
    pendown()
    a+=20
    d=randint(5,randint(10,80))
    setheading(a)
    for v in range(d):
     pensize(T(v,0,d,1,4))
     c=T(v,0,d,0,255)
     (right if heading()<90 or heading()>270 else left)(1)
     pencolor(c,2*c,w)
     fd(1)

draw_string("BONNE ANNEE 2023",0,206,(10,)*3,(0,)*3)
fill_rect(0,170,360,30,(0,)*3)

for x in range(0,180):
 for y in range(206,222):
  if sum(get_pixel(x,y))>0: fill_rect(2*x,2*y-242,2,2,(255,)*3)

while True:
 for x in range(0,360,2):
  for y in range(170,202,2):
   if sum(get_pixel(x,y)) > 0:
    (r,v,b) = choice([(255,0,0),(0,255,0),(255,255,0),(0,0,255),(255,0,255)])
    fill_rect(x,y,2,2,(r,v,b))
 sleep(.05)