Hey everyone, I have been working on this problem for school and I am stuck on how to finish a part of it. I was wondering if anyone could look at it and see what my problem is. I am using the addLine() function to draw several lines to form a tree and from there I want to generate 5 trees total using a for loop statement. I am getting stuck on how to make the for loop to solve this problem. Thank you for reading this post, and I appreciate any help that I receive.
def myHome():
canvas = getMediaPath("640X480.jpg")
canvasf = makePicture(canvas)
str = "This is my home."
addText(canvasf, 20,20,str, black)
addText(canvasf, 21,20,str, black)
addRect(canvasf, 299, 19, 301, 71)
addRectFilled(canvasf, 300, 20, 300, 70, cyan)
addRect(canvasf, 350, 90, 200, 150)
addRect(canvasf, 390, 120, 50, 50)
addRect(canvasf, 460, 120, 50, 50)
for x in range(40,240,50):
for y in range(90, 240):
addLine(canvasf, 40,70,40,230,makeColor(0,175,0))
addLine(canvasf, 20,90,40,120,makeColor(0,175,0))
addLine(canvasf, 20,130,40,160,makeColor(0,175,0))
addLine(canvasf, 40,120,60,90,makeColor(0,175,0))
addLine(canvasf, 40,160,60,130,makeColor(0,175,0))
writePictureTo(canvasf, r"E:\house.jpg")
explore(canvasf)
Garrett turner
Greenhorn
Joined: Oct 19, 2012
Posts: 2
posted
0
Thanks I figured it out, sorry to make a thread for nothing. This is what I came up with.