generated from mwc/project_drawing
	drawing.py
This commit is contained in:
		
							
								
								
									
										21
									
								
								drawing.py
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								drawing.py
									
									
									
									
									
								
							@@ -6,6 +6,7 @@
 | 
				
			|||||||
# (This is an animation of a sunrise.)
 | 
					# (This is an animation of a sunrise.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from turtle import *
 | 
					from turtle import *
 | 
				
			||||||
 | 
					from superturtle.animation import animate
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# define 3 objects
 | 
					# define 3 objects
 | 
				
			||||||
# sky, ground, sun
 | 
					# sky, ground, sun
 | 
				
			||||||
@@ -23,7 +24,6 @@ def sky():
 | 
				
			|||||||
        forward(300)
 | 
					        forward(300)
 | 
				
			||||||
        left(90)
 | 
					        left(90)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def ground():
 | 
					def ground():
 | 
				
			||||||
    for x in range(2):
 | 
					    for x in range(2):
 | 
				
			||||||
        forward(400)
 | 
					        forward(400)
 | 
				
			||||||
@@ -31,11 +31,15 @@ def ground():
 | 
				
			|||||||
        forward(150)
 | 
					        forward(150)
 | 
				
			||||||
        right(90)
 | 
					        right(90)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def sun():
 | 
					def sun():
 | 
				
			||||||
    forward(200)
 | 
					 | 
				
			||||||
    circle(75,360)
 | 
					    circle(75,360)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def sun_reposition():
 | 
				
			||||||
 | 
					    left(90)
 | 
				
			||||||
 | 
					    forward(20)
 | 
				
			||||||
 | 
					    right(90)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
penup() # reposition the turtle before drawing the 3 objects
 | 
					penup() # reposition the turtle before drawing the 3 objects
 | 
				
			||||||
right(180)
 | 
					right(180)
 | 
				
			||||||
forward(200)
 | 
					forward(200)
 | 
				
			||||||
@@ -54,9 +58,20 @@ fillcolor("black")
 | 
				
			|||||||
ground()
 | 
					ground()
 | 
				
			||||||
end_fill()
 | 
					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
 | 
					    begin_fill() # draw the sun
 | 
				
			||||||
    fillcolor("red")
 | 
					    fillcolor("red")
 | 
				
			||||||
    sun()
 | 
					    sun()
 | 
				
			||||||
 | 
					    sun_reposition()
 | 
				
			||||||
    end_fill()
 | 
					    end_fill()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
input()
 | 
					input()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user