Created
March 19, 2022 07:59
-
-
Save touatily/559ad61af7ca073ed5d430c692200177 to your computer and use it in GitHub Desktop.
Morocco Flag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
import math | |
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() | |
def ds(tur, center, rayon, rot, color, fill=True, thickness=1): | |
tur.width(thickness) | |
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() | |
if fill: | |
tur.begin_fill() | |
for i in range(5): | |
tur.fd(branche) | |
tur.right(144) | |
tur.end_fill() | |
tur.up() | |
t = turtle.Turtle() | |
t.speed(1) | |
unit = 100 | |
width = 4 * unit | |
height = 6 * unit | |
A = 1.09 * unit | |
B = A/20 | |
drawRect(t, (-height//2, width//2), (height//2, -width//2), "black", "#c1272d") | |
ds(t, (0, 0), unit, 0, "#006233", False, B) | |
t.hideturtle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment