Skip to content

Instantly share code, notes, and snippets.

@touatily
Created March 3, 2024 15:21
Show Gist options
  • Save touatily/b2d101ae47477b02cfd943db31ed2b37 to your computer and use it in GitHub Desktop.
Save touatily/b2d101ae47477b02cfd943db31ed2b37 to your computer and use it in GitHub Desktop.
Palestine flag in Python
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