toaster.py

Created by evann-dreumont

Created on May 10, 2021

1.13 KB


from math import *
from kandinsky import *
from turtle import *

def cercle(x0,y0,r,c,e):
 for i in range(2*e):
   xd=x0-int((r-i*0.5)/sqrt(2))
   xf=x0+int((r-i*0.5)/sqrt(2))
   for x in range(xd,xf+1):
     x1=x
     y1=y0+int(sqrt((r-i*0.5)**2-(x-x0)**2))
     set_pixel(x,y1,c)
     for j in range(3):
       x2=x0+y1-y0
       y2=y0+x0-x1
       set_pixel(x2,y2,c)
       x1,y1=x2,y2

def cercle_plein(x0,y0,r,c1,e,c2):
 cercle(x0,y0,r,c1,e)
 cercle(x0,y0,r-e,c2,r-e)

def cercle_grade(x0,y0,R,c1,e,c2):
 for i in range(R):
   r=c1[0]+i*(c2[0]-c1[0])//R
   g=c1[1]+i*(c2[1]-c1[1])//R
   b=c1[2]+i*(c2[2]-c1[2])//R
   cercle(x0,y0,i,color(r,g,b),1)
  
c_noir=[0,0,0] 
c_bleu=[0,0,0]
cercle_grade(160,111,197,c_bleu,10,c_noir)
cercle_grade(160,111,40,c_soleil2,2,c_bleu)
cercle_grade(160,111,16,c_soleil,2,c_soleil2)

pencolor(252,252,252)
v=0
while v < 150:
    forward(2*5)
    left(144)
    forward(2*5)
    left(144)
    forward(2*5)
    left(144)
    forward(2*5)
    left(144)
    forward(2*5)
    left(144)
    v = v + 1
    penup()
    avancer=randint(5,60)
    angle=randint(5,40)
    forward(avancer)
    left(angle)
    pendown()

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.