-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeather Visualization.py
More file actions
65 lines (56 loc) · 1.49 KB
/
Weather Visualization.py
File metadata and controls
65 lines (56 loc) · 1.49 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import turtle
import random
# Set up the screen
screen = turtle.Screen()
screen.setup(width=800, height=600)
screen.bgcolor("lightblue")
# Create the Turtle objects
sun_turtle = turtle.Turtle()
cloud_turtle = turtle.Turtle()
rain_turtle = turtle.Turtle()
# wind_turtle = turtle.Turtle()
# Function to draw the sun
def draw_sun():
sun_turtle.penup()
sun_turtle.goto(-300, 200)
sun_turtle.pendown()
sun_turtle.color("yellow")
sun_turtle.begin_fill()
sun_turtle.circle(50)
sun_turtle.end_fill()
# Function to draw clouds
def draw_cloud(x, y):
cloud_turtle.penup()
cloud_turtle.goto(x, y)
cloud_turtle.pendown()
cloud_turtle.color("white")
cloud_turtle.begin_fill()
for _ in range(2):
cloud_turtle.circle(30, 180)
cloud_turtle.forward(60)
cloud_turtle.end_fill()
# Function to draw raindrops
def draw_rain(x, y):
rain_turtle.penup()
rain_turtle.goto(x, y)
rain_turtle.pendown()
rain_turtle.color("blue")
rain_turtle.shape("triangle")
rain_turtle.setheading(270)
rain_turtle.shapesize(0.2, 0.5)
rain_turtle.stamp()
# Function to simulate wind
def simulate_wind():
for _ in range(20):
x = random.randint(-350, 350)
y = random.randint(-100, 100)
draw_cloud(x, y)
for _ in range(100):
x = random.randint(-350, 350)
y = random.randint(-100, 100)
draw_rain(x, y)
# Draw the initial scene
draw_sun()
simulate_wind()
# Close the window on click
screen.exitonclick()