# 9C
#  Hold and drag the mouse to create the background squares.  As different
#  squares are drawn, streamers pop out or recede into the background.
import math
g.norefresh()



def slats(x1, y1, x2, y2, height):
	for a in range(0, height):
       		g.line(x1, y1, x2, y2)
            	y1 = y1 - 1
	        y2 = y2 - 1

def color_set(x1, y1, x2, y2, height, r):
	for a in range(r-10, r):
		g.pen(a)
		slats(x1, y1, x2, y2, height)
		#g.pause(100)
		y1 = y1+20
		y2 = y2+20   



####### Layering Smeary random function MSTRING's problemset with deoderant
rseed = g.getTime(4)
def random(r):
	bb = 198621
	mm = (98621+g.getTime(4))
	bl = (long(rseed)*bb+1)
	temp = bl%mm
	return int(temp%r), int(temp)


g.paper(0)
g.refresh()



while(1):
			  
	color_set(0, 10, 18, 20, 10, 10)
	color_set(20, 20, 38, 10, 10, 20)
	color_set(40, 10, 58, 20, 10, 30)
	color_set(60, 20, 78, 10, 10, 40)
	color_set(80, 10, 88, 20, 10, 50)
	color_set(90, 20, 98, 10, 10, 60)

        color_set(100, 10, 108, 20, 10, 60)
	color_set(110, 20, 118, 10, 10, 50)
	color_set(120, 10, 138, 20, 10, 40)
	color_set(140, 20, 158, 10, 10, 30)
	color_set(160, 10, 178, 20, 10, 20)
	color_set(180, 20, 198, 10, 10, 10)
	g.refresh()
	if(g.getMouse(3) == 100):
		mx = g.getMouse(1)
		my = g.getMouse(2)
		rand1, rseed = random(50)
		rand2, rseed = random(50)
		color, rseed = random(100)
		g.field(mx + rand1, my + rand2, mx -rand1, my-rand2, color)
		g.refresh()