Drawing Lines Loop
I am a beginner, I am in my first java course so please take it easy on me. But I have written this code drawing 15 lines. I am stuck on how to make another loop to start the lines again in each corner.
Here is my code thus far, and the result I am looking for. If anyone can help me or write show me the extra input needed to reach this picture please let me know.
public class DrawOneSetOfLines extends JPanel
public static void main(String args)
DrawOneSetOfLines panel = new DrawOneSetOfLines();
JFrame application = new JFrame();
public void paintComponent(Graphics g)
int linesToDraw = 15;
int width = getWidth();
int height = getHeight();
int number, y, x, dy, dx;
x = 0;
y = height;
number = 15;
dx = width / number;
dy = height / number;
for( int i = 1; i < number; i++ )
x += dx;
y -= dy;
g.drawLine( 0, 0, x, y );
Re: Drawing Lines Loop
Please edit your post and wrap your code with code tags:
<YOUR CODE HERE>
to get highlighting and preserve formatting.
Is there an algorithm that will draw the lines to make the image that you want drawn? Please post it so it can be compared to the code that was posted.