Skip to content

Instantly share code, notes, and snippets.

@touatily
Created November 12, 2021 19:13
Show Gist options
  • Save touatily/a4b4f4d3ca55029baab3deaacece0bad to your computer and use it in GitHub Desktop.
Save touatily/a4b4f4d3ca55029baab3deaacece0bad to your computer and use it in GitHub Desktop.
Flag of Europe
import turtle
import math
def drawStar(tur, center, rayon, rot, color):
tur.up()
tur.color(color, color)
tur.goto(center[0] + (rayon * math.sin(math.radians(rot))),
center[1] + (rayon * math.cos(math.radians(rot))))
branche = rayon * 2 * math.cos(math.radians(18))
tur.setheading(-rot - 72)
tur.down()
tur.begin_fill()
for i in range(5):
tur.fd(branche)
tur.right(144)
tur.end_fill()
tur.up()
def drawRect(tur, xy1: tuple, xy2: tuple, color:str, fill:str):
tur.up()
tur.color(color, fill)
tur.goto(xy1[0], xy1[1])
tur.begin_fill()
tur.down()
tur.goto(xy1[0], xy2[1])
tur.goto(xy2[0], xy2[1])
tur.goto(xy2[0], xy1[1])
tur.goto(xy1[0], xy1[1])
tur.end_fill()
t = turtle.Turtle()
t.speed(10)
u = 200
A = 2 * u
B = 3 * u
drawRect(t, (-B//2, A//2), (B//2, -A//2), "black", "#003399")
R = 2 / 3 * u
taille = 2/9 * u / 2
for i in range(12):
angle = i * 360 / 12
x, y = (R * math.sin(math.radians(angle)),
R * math.cos(math.radians(angle)))
drawStar(t, (x, y), taille, 0, "#FFCC00")
t.goto(x, y)
t.hideturtle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment