Sign in to follow this  

Computer Science Java School question

This topic is 4104 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hullo, I am in a computer science class at my High School and we are using Java as the language. So far we've made applets and applications using data types, and basic graphics like drawLine, fillRect, drawRect, drawOval, etc. Just recently we've begun loops, and this is a lab we're going to be working on. Image Hosted by ImageShack.us Problem is, I've been messing around and cannot achieve that result. The paper said it is composed of merely straight lines, but it doesn't look like it, and obviously doesn't have an even scale.

Share this post


Link to post
Share on other sites
Here's what seems to be happening:

Take your first line. Draw it from the bottom left hand corner to the low right. Your next line starts a little to the right (but still on the bottom) of that corner and goes a little higher (but still to the far right). Your next line is a little more right and a little higher. Until eventually your final line is drawn almost at the very right hand corner and all the way to the top.

In psuedocode, it might look something like this:

startX = 0, startY = windowY, endX = windowX, endY = windowY - 10;
for (i = 1 to 50)
{
drawLine(startX, startY, endX, endY)
startX += 10
endY -= 10
}

Hope that helps,
--Brian

Share this post


Link to post
Share on other sites

This topic is 4104 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this