Exemplo n.º 1
0
def space_painting(t, scale, x_offset = 0, y_offset = 0):
    '''
    Function calling a space scene within a frame
    '''
    t.pensize(6)
    t.pencolor('RoyalBlue4')
    bsl.rectangle(t, x_offset-150, y_offset-100, 200, 250)
    t.pensize(1)
    bsl.myScene(t, x_offset-80, y_offset, scale = 1/4)
Exemplo n.º 2
0
def mondrian_painting(t, scale, x_offset = 0, y_offset = 0):
    '''
    Function calling mondrian within a frame
    '''
    t.pencolor('Skyblue')
    t.pensize(8)
    bsl.rectangle(t, x_offset-100, y_offset-100, 250, 250)
    t.pensize(2)
    bsl.mondrian(t, 50, 100, 1 * scale, number = 80)
Exemplo n.º 3
0
def MountScene():
    '''
	This allows the user to use the command prompt to control several aspects of the scene
	including position, number of mountains drawn in the scene, scale of the scene,
	the color of the sky, the color of the mountains, and the color of the sun or moon
	at the top of the scene. The below variable definitions set default values for these
	parameters in case the user forgets to input anything into the command prompt.  
	'''
    x = 0
    y = 0
    N = 30
    scale = 0.3
    skycolor = "sky blue"
    mountcolor = "green"
    moonsuncolor = "yellow"

    if len(sys.argv) > 7:
        x = int(sys.argv[1])  #Allows user to input x coordinate of the scene.
        y = int(sys.argv[2])  #Allows user to input y coordinate of the scene.
        N = int(
            sys.argv[3])  #Allows user to choose number of mountains in scene
        scale = float(sys.argv[4])  #Allows user to choose scale of scene.
        skycolor = str(sys.argv[5])  #Allows user to choose color of sky.
        mountcolor = str(
            sys.argv[6])  #Allows user to choose color of mountains in scene.
        moonsuncolor = str(
            sys.argv[7])  #Allows user to choose color of moon or sun.

    bsl.rectangle(x + -400 * scale, y + -400 * scale, 800 * scale, 800 * scale,
                  True, skycolor)
    '''
	This is what fills the rectanglular sky the color the user specifies
	'''
    bsl.rectangle(x + -400 * scale, y + -400 * scale, 800 * scale, 300 * scale,
                  True, "blue")
    for i in range(N):
        '''
		Draws a mountain range by drawing N triangular mountains of random size from
		range 20 to 100 pixels and at random coordinate ranging from (-400,-400) 
		to (100, 100)
	
		'''
        bsl.triangle(random.randint(x + -400 * scale, x + 200 * scale),
                     random.randint(y + -100 * scale, y + 100 * scale),
                     random.randint(30 * scale, 200 * scale), True, mountcolor)

    bsl.circle(x + 250 * scale, y + 250 * scale, 30 * scale, True,
               moonsuncolor)
    '''
	This draws a sun/moon at the upper right hand corner of the sky and colors it
	in whatever color the user specifies. 
	'''

    turtle.up()
    turtle.forward(100)
    raw_input("Press enter to exit")
Exemplo n.º 4
0
def main():
    x = 0
    y = 0
    N = 30
    scale = 0.3
    skycolor = "sky blue"
    mountcolor = "green"
    moonsuncolor = "yellow"

    if len(sys.argv) > 7:
        x = int(sys.argv[1])
        y = int(sys.argv[2])
        N = int(sys.argv[3])
        scale = float(sys.argv[4])
        skycolor = str(sys.argv[5])
        mountcolor = str(sys.argv[6])
        moonsuncolor = str(sys.argv[7])

    bsl.rectangle(x + -400 * scale, y + -400 * scale, 800 * scale, 800 * scale,
                  True, skycolor)
    '''
	This is what fills the rectanglular sky blue
	'''
    bsl.rectangle(x + -400 * scale, y + -400 * scale, 800 * scale, 300 * scale,
                  True, "blue")
    for i in range(N):
        '''
		Draws a mountain range by drawing N triangular mountains of random size from
		range 20 to 100 pixels and at random coordinate ranging from (-400,-400) 
		to (100, 100)
	
		'''
        bsl.triangle(random.randint(x + -400 * scale, x + 200 * scale),
                     random.randint(y + -100 * scale, y + 100 * scale),
                     random.randint(30 * scale, 200 * scale), True, mountcolor)

    bsl.circle(x + 250 * scale, y + 250 * scale, 30 * scale, True,
               moonsuncolor)
    '''
	This draws a sun at the upper right hand corner of the sky. 
	'''

    turtle.up()
    turtle.forward(100)
    raw_input("Press enter to exit")
Exemplo n.º 5
0
def Museum():
	'''
	This creats a museum scene which draws two framed "paintings". The "paintings" are
	the two scenes from last week. 
	'''
	turtle.color("brown")
	bsl.rectangle(-250,-50,300,300,False,"White")
	'''
	This draws a brown square frame of300 pixels drawn at (-250,-50) 
	around the lighthouse scene
	'''
	bsl.myScene(-100,100,0.4)
	'''
	This draws the lighthouse scene at position (-100,100) and
	the scene is drawn at 0.4 times its original size. 
	'''
	turtle.color("black")
	bsl.rectangle(113,13,175,175,False,"White")
	'''
	Then it draws a black square frame of 175 pixels at position (113,13) around th
	'''
	bsl.myOtherScene(200,100,0.2)
	'''
Exemplo n.º 6
0
def museum(t, scale, x_offset = 0, y_offset = 0):
    '''
    Function calling various painting scenes within museum scenes
    '''
    space_painting(t, x_offset = -200, y_offset = 0, scale = 1/8)
    mondrian_painting(t, 1/4)
    t.pensize(6)
    t.pencolor('gold4')
    bsl.rectangle(t, 230, 25, 220, 220)
    bsl.goto(t,350,120)
    ex2.star_painting(t,1)
    t.pensize(6)
    t.pencolor('peru')
    t.fillcolor('peru')
    t.begin_fill()
    bsl.rectangle(t, x_offset-500, y_offset-250, 1000, 50)
    t.end_fill()
    bsl.circle(t,x_offset-400, y_offset-300, 1/2, 'SandyBrown')
    bsl.circle(t,x_offset-250, y_offset-300, 1/2, 'SandyBrown')
    bsl.circle(t,x_offset-100, y_offset-300, 1/2, 'SandyBrown')
    bsl.circle(t,x_offset+50, y_offset-300, 1/2, 'SandyBrown')
    bsl.circle(t,x_offset+200, y_offset-300, 1/2, 'SandyBrown')
    bsl.circle(t,x_offset+350, y_offset-300, 1/2, 'SandyBrown')
Exemplo n.º 7
0
def DayNight():
'''
This uses sys.argv to allow the user to input a statement that will dictate certain 
aspects of the lighthouse scene so that it either produces a scene of what the lighthouse
image would look like during the day or at night. 
'''
	if len( sys.argv ) > 1:
		TOD = str(sys.argv[1]) #asks user for time of day
		'''
		These varable definitions specify initial x and y coordinates at which various
		aspects of the lighthouse scene will be drawn at and will specify the scale at 
		which everything in the scene is drawn via the scene parameter. 
		'''
		x=-100
		y=0
		scale=0.7
		
		if TOD=="Day":
			'''
			This creates the lighthouse scene to reflect daytime, so it makes
			the sky sky blue and draws a sun high up in the sky. 
			'''
			bsl.rectangle(x+-350*scale,y+-350*scale,700*scale,150*scale,True,"tan")
			bsl.rectangle(x+-350*scale,y+-200*scale,700*scale,150*scale,True,"blue")
			bsl.rectangle(x+-350*scale,y+-50*scale,700*scale,400*scale,True,"sky blue")
			bsl.rectangle(x+250*scale,y+-50*scale,100*scale,150*scale,True,"gray")
			bsl.drawLighthouse(x+285*scale,y+100*scale,30*scale,40*scale,0.8,True)
			bsl.circle(x+-220*scale,y+225*scale,50*scale,True,"Yellow")
			turtle.up()
			turtle.forward(-200*scale)
		elif TOD=="Night":
			'''
			This creates the lighthouse to reflect nighttime, so it makes the sky purple
			and draws a moon lower in the sky.  
			'''
			bsl.rectangle(x+-350*scale,y+-350*scale,700*scale,150*scale,True,"tan")
			bsl.rectangle(x+-350*scale,y+-200*scale,700*scale,150*scale,True,"blue")
			bsl.rectangle(x+-350*scale,y+-50*scale,700*scale,400*scale,True,"purple")
			bsl.rectangle(x+250*scale,y+-50*scale,100*scale,150*scale,True,"gray")
			bsl.drawLighthouse(x+285*scale,y+100*scale,30*scale,40*scale,0.8,True)
			bsl.circle(x+-220*scale,y+150*scale,50*scale,True,"salmon")
			turtle.up()
			turtle.forward(-200*scale)