-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rangoli.py
44 lines (35 loc) · 1.05 KB
/
Rangoli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import turtle
import random
# Setup the screen
screen = turtle.Screen()
screen.bgcolor("white")
screen.title("Rangoli Making Game")
# Create a turtle for drawing
pen = turtle.Turtle()
pen.speed(0) # Fastest drawing speed
pen.width(2)
# Colors list
colors = ["red", "blue", "green", "yellow", "orange", "purple", "pink"]
# Function to draw a circle pattern
def draw_circle(radius, color):
pen.color(color)
pen.circle(radius)
# Function to draw a rangoli pattern
def draw_rangoli(size):
for i in range(12): # 12 patterns in a circle
draw_circle(size, random.choice(colors))
pen.right(30) # Turn the pen to create circular patterns
# Function to start the game
def start_game():
pen.penup()
pen.goto(0, -150) # Starting point
pen.pendown()
# Draw multiple rangolis with increasing size
for size in range(50, 150, 20):
draw_rangoli(size)
pen.penup()
pen.goto(0, 0)
pen.hideturtle()
screen.exitonclick() # Exit on click
# Start the game
start_game()