fleurs.py

Created by numworks

Created on April 08, 2022

1.51 KB

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

penup()

rects = [
(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-5*R,centerI+5*R):
for j in range(centerJ-5*R,centerJ+5*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))

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

def flower():
petal()
petal()
petal()
petal()
petal()

width(2)
goto(0,-2)
pendown()
pencolor('red')
flower()
penup()
goto(-90, -10)
pendown()
pencolor('pink')
flower()

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

#sun()
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)```