Created
March 3, 2024 15:21
-
-
Save touatily/b2d101ae47477b02cfd943db31ed2b37 to your computer and use it in GitHub Desktop.
Palestine flag in Python
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 | |
import time | |
def drawTriangle(tur, xy1: tuple, xy2: tuple, xy3: tuple, color:str, fill:str): | |
tur.up() | |
tur.color(color, fill) | |
tur.goto(xy1[0], xy1[1]) | |
tur.begin_fill() | |
tur.down() | |
tur.goto(xy2[0], xy2[1]) | |
tur.goto(xy3[0], xy3[1]) | |
tur.goto(xy1[0], xy1[1]) | |
tur.end_fill() | |
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() | |
screen = turtle.Screen() | |
screenTk = screen.getcanvas().winfo_toplevel() | |
screenTk.attributes("-fullscreen", True) | |
factor = 200 | |
width = 6 * factor | |
height = 3 * factor | |
turtle.bgcolor("grey") | |
t = turtle.Turtle() | |
t.speed(10) | |
drawRect(t, (-width//2, height//2), (width//2, -height//2), "white", "white") | |
drawRect(t, (-width//2, height//2), (width//2, height//6), "black", "black") | |
drawRect(t, (-width//2, -height//6), (width//2, -height//2), "green", "green") | |
drawTriangle(t, (-width//2, height//2), (-width//6,0), (-width//2, -height//2), "red", "red") | |
t.hideturtle() | |
input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment