Files
project_drawing/drawing.py
2025-09-20 11:47:00 -04:00

78 lines
1.5 KiB
Python

# drawing.py
# ----------
# Nelson Mason
# updated 9-19-2025
# Due by 9-29-2025
# (This is an animation of a sunrise.)
from turtle import *
from superturtle.animation import animate
# define 3 objects
# sky, ground, sun
# In the actual animation, the sun will start off entirely below the horizon,
# (where the sky meets the ground), hidden by the ground, and will slowly rise (move up the screen),
# with the sun, sky, and ground changing color. The disk of the sun will
# be apparent only in the sky, as it rises. The elapsed_time will be linked to the
# animation frames. I will be using color shading techniques in the animation.
def sky():
for x in range(2):
forward(400)
left(90)
forward(300)
left(90)
def ground():
for x in range(2):
forward(400)
right(90)
forward(150)
right(90)
def sun():
circle(75,360)
def sun_reposition():
left(90)
forward(20)
right(90)
penup() # reposition the turtle before drawing the 3 objects
right(180)
forward(200)
left(90)
forward(50)
left(90)
pendown()
begin_fill() # draw the sky
fillcolor("dark blue")
sky()
end_fill()
begin_fill() # draw the ground
fillcolor("black")
ground()
end_fill()
penup()
right(90)
forward(150)
left(90)
forward(200)
pendown()
# for frame in animate(40, loop=True):
# x = frame.interpolate(0,15)
for x in range(15):
begin_fill() # draw the sun
fillcolor("red")
sun()
sun_reposition()
end_fill()
input()