import java.awt.Color;
import java.io.IOException;
/*
* A program to print out various scintillation grids and a student designed
drawing.
*/
public class ScintillationGrid {
// Main method that creates the DrawingPanel with scintillation grids.
// Restricted to chapters 1 - 3 of Building Java Programs
public static void main(String[] args) {
/* In the final version of the program DO NOT call method drawingOne
from main or anywhere else in the program */
final int WIDTH = 950;
final int HEIGHT = 650;
DrawingPanel dp = new DrawingPanel(WIDTH, HEIGHT);
dp.setBackground(Color.CYAN);
Graphics g = dp.getGraphics();
// Add your four methods calls to draw the four
// required scintillation grids here.
drawGrid(g, 0, 0, 75, 3, 16);
drawGrid(g, 400, 50, 50, 6, 12);
drawGrid(g, 50, 400, 100, 1, 20);
drawGrid(g, 500, 500, 15, 7, 4);
// do not alter this line of codes
saveDrawingPanel(dp, "grid.png");
}
// The drawGrid method is responsible for drawing the scintillation
// grids, which are then called upon by the main method.
public static void drawGrid(Graphics g, int x, int y, int size,
int lineNumber, int lineThickness){
// Establishes the grid
g.setColor(Color.BLACK);
int bigSquare = size + ((size + lineThickness) * lineNumber);
g.fillRect(x, y, bigSquare, bigSquare);
// Draws the vertical and horizontal lines repectively in the grid
for(int i = 1; i <= lineNumber; i++){
g.setColor(Color.GRAY);
g.fillRect( x + ((size * i) + (lineThickness * (i - 1))),
y, lineThickness, bigSquare);
g.fillRect( x, y + ((size * i) + (lineThickness * (i - 1))),
bigSquare, lineThickness);
}
This study source was downloaded by 100000858936669 from CourseHero.com on 02-02-2023 23:09:44 GMT -06:00
https://www.coursehero.com/file/56363391/ScintillationGridsjava/