try_printemps.py

Created by elodie-gamot

Created on March 21, 2022

1.91 KB


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

penup()
hideturtle()

rects = [
(0,0,340,180,(65,165,245)),
(0,180,340,60,(0,128,0))]
for r in rects:
  fill_rect(*r)

def fillEllipsis(centerI, centerJ, a, b, theta, R, color):
  a2 = a*a
  b2 = b*b
  for i in range(centerI-6*R,centerI+6*R):
    for j in range(centerJ-6*R,centerJ+6*R):
      deltaI = i-centerI
      deltaJ = j-centerJ
      x = cos(theta)*deltaI + sin(theta)*deltaJ
      y = sin(theta)*deltaI - cos(theta)*deltaJ
      if (x*x/a2+y*y/b2 <= R):
        set_pixel(i, j, color)

fillEllipsis(185,175, 2, 5, 4,3,(111,204,42))
fillEllipsis(175,175, 5, 2, 4,3,(111,204,42))
fillEllipsis(40,175, 5, 2, 4,3,(111,204,42))
fillEllipsis(50,175, 2, 5, 4,3,(111,204,42))

pendown()

def petal():
    circle(20, 90)
    left(90)
    circle(20, 90)
    left(18)
    
def flower():
    petal()
    petal()
    petal()
    petal()
    petal()


penup()
goto(-90,-10)
pendown()
pencolor('green')
right(140)
circle(67,56)
penup()
goto(21,-64)
pendown()
left(166)
circle(70,54)
penup()

#red
fillEllipsis(167,103, 3, 8, 3.75,3,(255,0,0))
fillEllipsis(150,103, 3, 8, -4,3,(255,0,0))
fillEllipsis(170,115, 3, 8, -7.5,3,(255,0,0))
fillEllipsis(162,120, 3, 8, 0,3,(255,0,0))
fillEllipsis(152,119, 3, 8, 4,3,(255,0,0))
#pink
fillEllipsis(58,127, 3, 8, 3.75,3,(255,169,166))
fillEllipsis(78,107, 3, 8, 4,3,(255,169,166))
fillEllipsis(78,122, 3, 8, -4.25,3,(255,169,166))
fillEllipsis(60,110, 3, 8, -3.75,3,(255,169,166))
fillEllipsis(68,128, 3, 8, -0.25,3,(255,169,166))

fillEllipsis(270,45,8,8,8,8,(255,215,0))
pencolor('yellow')
width(2)
goto(111,40)
pendown()
goto(111,25)
penup()
goto(111,90)
pendown()
goto(111,105)
penup()
goto(135,67)
pendown()
goto(150,67)
penup()
goto(85,67)
pendown()
goto(70,67)
penup()
goto(128,47)
pendown()
goto(140,37)
penup()
goto(94,85)
pendown()
goto(82,95)
penup()
goto(94,47)
pendown()
goto(82,37)
penup()
goto(128,85)
pendown()
goto(140,95)

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.