aspose file tools*
The moose likes Jython/Python and the fly likes Jython problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "Jython problem?" Watch "Jython problem?" New topic
Author

Jython problem?

Garrett turner
Greenhorn

Joined: Oct 19, 2012
Posts: 2
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)




[Thumbnail for house.jpg]

Garrett turner
Greenhorn

Joined: Oct 19, 2012
Posts: 2
Thanks I figured it out, sorry to make a thread for nothing. This is what I came up with.




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)
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))
x = 60
for i in range(4):
addLine(canvasf, 30+x, 70, 30+x,230, makeColor(0,175,0))
addLine(canvasf, 10+x, 90, 30+x,120,makeColor(0,175,0))
addLine(canvasf, 10+x,130,30+x,160,makeColor(0,175,0))
addLine(canvasf, 30+x,120,50+x,90,makeColor(0,175,0))
addLine(canvasf, 30+x,160,50+x,130,makeColor(0,175,0))
x = x + 60
explore(canvasf)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Jython problem?
 
Similar Threads
How to Retrieve DOM
Prepared?
How to retrieve DOM
Just Java 2 clock class help required (Resolved)
Array Testing Output Confusion