################################ No.3 Log Cabin ############################

beginPos = turtle.pos()
frameW = glbBlockLength/(4*2+1)
frameH = glbBlockLength - frameW
dashGap = frameW/6                          # dash line's gap
dashLength = frameW/3                       # dash line's length
def drawOneframe(fn):                       # define the function for 1 frame
	for i in range(0,2):
		turtle.forward(frameW)              # width
		turtle.right(90)
		turtle.forward(frameH-fn*frameW*2)  # height
		turtle.right(90)
def drawDashFrame(fn):                      # draw  dash line inside the frame
	turtle.pencolor("#EEEEEE")              # override turtle's line color
	turtle.width(1)                         # override turtle's line width to 1
	# go to inside of the frame:
	turtle.penup()
	for i in range (0,2):
		turtle.right( 90 * ( 1 - i * 2 ) )
		turtle.forward(dashGap)   
	turtle.pendown()
	# draw the dash line rectangle:
	for i in range (0,2):
		dashline((frameW-dashGap*2), dashLength) # width
		turtle.right(90)
		dashline((frameH-fn*frameW*2-dashGap*2), dashLength) # height
		turtle.right(90)
	turtle.width(glbLineWidth)              #reset turtle's line width
	# go back to the frame's original position
	turtle.penup()
	for i in range (0,2):
		turtle.left( 90 * ( 1 - i * 2 ) )
		turtle.forward( dashGap * ( 1 - i * 2 ) )
	turtle.pendown()
	turtle.pencolor(glbPenColor)            #reset turtle's line color
	
def moveToNextFrame(fn):
	turtle.penup()
	turtle.forward(glbBlockLength-fn*frameW*2)
	turtle.pendown()
	turtle.right(90)

def moveToNextLayer():
	turtle.penup()
	for i in range (0,2):
		turtle.forward(frameW)
		turtle.right( 90 * ( 1 - i * 2 ) )
	turtle.pendown()

## draw the log cabin
def logCabin(color1, color2, color3, color4, color5):
	beginPos = turtle.pos()
	frameColors = [color5, color4, color3, color2, color1]
	turtle.write("Log Cabin")
	turtle.begin_fill()
	turtle.fillcolor(color1)
	drawBlockSq()
	turtle.end_fill()

	for i in range (0,4):
		for b in range (0,4):
			turtle.begin_fill()
			turtle.fillcolor(frameColors[i])
			drawOneframe(i)
			turtle.end_fill()
			drawDashFrame(i)
			moveToNextFrame(i)
		moveToNextLayer()
   
		   
	#reset position
	gotoBeginPos()
