Question
Write a program, which displays straight lines inside a rectangle from one side to a perpendicular side. The lines must be drawn in such a
Write a program, which displays straight lines inside a rectangle from one side to a perpendicular side. The lines must be drawn in such a way that both the starting points of the lines on one side and the ending points on the other side are equidistant along the sides. The size of the rectangle is 980 pixels width by 630 pixels height.
For full points: repeat the entire process by drawing a small copy of the border inside the blank space of the design.
Code I have so far:
import java.awt.*; import java.applet.*; public class graphics extends Applet { public void paint(Graphics g) { int width = 980; int height = 630; //int x1 = 10; //int y1 = 640; //int x2 = 990; //int y2 = 640; int x1 = 990; int y1 = 10; int x2 = 490; int y2 = 640; g.drawRect(10,10,width,height);
// the x1, x2, y1,y2 coordinates // add a for loop that increments for (int i = 0 ; i
// Draw bottom-left corner //loop will run 51 times //x increment or decrement by some number/50 //y increment or decrement by some number/50 // Draw top-right corner // Draw top-left corner } } }
Applet Viewer: Graphics Labo2v110.class plast Applet Viewer: Graphics Labo2v110.class plast
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started