generated from mwc/project_drawing
	drawing.py
This commit is contained in:
		
							
								
								
									
										24
									
								
								drawing.py
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								drawing.py
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
			
		||||
# drawing.py
 | 
			
		||||
# ----------
 | 
			
		||||
# Nelson Mason
 | 
			
		||||
# updated 9-21-2025
 | 
			
		||||
# updated 9-22-2025
 | 
			
		||||
# Due by 9-29-2025
 | 
			
		||||
# (This is an animation of a sunrise.)
 | 
			
		||||
 | 
			
		||||
@@ -10,15 +10,20 @@ 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. I will be using color shading techniques in the animation.
 | 
			
		||||
 | 
			
		||||
# I played around with the RGB settings. I left out drawing the sun 
 | 
			
		||||
# casting a shadow on the ground while rising.
 | 
			
		||||
# Perhaps for another project?
 | 
			
		||||
 | 
			
		||||
# YOU CAN'T BEAT MOTHER NATURE FOR A SUNRISE!
 | 
			
		||||
 | 
			
		||||
def sky():
 | 
			
		||||
    begin_fill() # draw the sky
 | 
			
		||||
    fillcolor("dark blue")   
 | 
			
		||||
    fillcolor(0.05, 0.05, a/275) # as the sun rises sky color changes from black to blue
 | 
			
		||||
    for x in range(2):
 | 
			
		||||
        forward(400)
 | 
			
		||||
        left(90)        
 | 
			
		||||
@@ -28,7 +33,7 @@ def sky():
 | 
			
		||||
 | 
			
		||||
def ground():
 | 
			
		||||
    begin_fill() # draw the ground
 | 
			
		||||
    fillcolor("black")
 | 
			
		||||
    fillcolor(0.05, a/1100, 0.05) # as the sun rises ground color changes from black to dark green
 | 
			
		||||
    for x in range(2):
 | 
			
		||||
        forward(400)
 | 
			
		||||
        right(90)        
 | 
			
		||||
@@ -36,10 +41,11 @@ def ground():
 | 
			
		||||
        right(90)
 | 
			
		||||
    end_fill()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def sun():
 | 
			
		||||
    begin_fill() # draw the sun
 | 
			
		||||
    fillcolor("red")
 | 
			
		||||
    circle(-62,360) 
 | 
			
		||||
    fillcolor(1, a/550, 0) # as the sun rises sun color changes from red to orange
 | 
			
		||||
    circle(-75,360) 
 | 
			
		||||
    end_fill()
 | 
			
		||||
 | 
			
		||||
def sun_position(a): # this must be called to get the sun to move up (rise)
 | 
			
		||||
@@ -49,7 +55,9 @@ def sun_position(a): # this must be called to get the sun to move up (rise)
 | 
			
		||||
    right(90)
 | 
			
		||||
    pendown()
 | 
			
		||||
 | 
			
		||||
for frame in animate(frames=1000):
 | 
			
		||||
for frame in animate(frames=550, loop=True):
 | 
			
		||||
    a = frame.interval=1100 # the frames-to-interval ratio controls the animation speed
 | 
			
		||||
    a = frame.interpolate(0, 275) # low and high positions of the sun as it rises
 | 
			
		||||
    penup() # reposition the turtle before drawing the sky
 | 
			
		||||
    right(180)
 | 
			
		||||
    forward(200)
 | 
			
		||||
@@ -62,8 +70,6 @@ for frame in animate(frames=1000):
 | 
			
		||||
    forward(200) # starting the drawing of the sun right on the horizon
 | 
			
		||||
    # makes it easier to calculate everything else
 | 
			
		||||
    pendown()
 | 
			
		||||
    a = frame.interval=200 # the frames-to-interval ratio controls the animation speed
 | 
			
		||||
    a = frame.interpolate(0, 275) # low and high positions of the sun as it rises
 | 
			
		||||
    sun_position(a)
 | 
			
		||||
    sun() # draws the sun   
 | 
			
		||||
    penup() # reposition the turtle before drawing the ground
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user