//GrayScale.java //random points in gray scale 1-10 import java.awt.*; import javax.swing.*; public class GrayScale extends JApplet { int rows, cols, height, width, loops; public void init() { String input; input = JOptionPane.showInputDialog("Enter # rows"); rows = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter # columns"); cols = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter row height"); height = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter column width"); width = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter # iterations"); loops = Integer.parseInt(input); /* input = JOptionPane.showInputDialog("Random percentage rock"); percent = Integer.parseInt(input); input = JOptionPane.showInputDialog("Pixel scale factor"); scale = Integer.parseInt(input); input = JOptionPane.showInputDialog("Seepage rule:"+ "\n1. above or either diagonal"+ "\n2. above or both diagonals"); rule = Integer.parseInt(input); sideflow = JOptionPane.showInputDialog("Side flow (yes or no)"); */ } public void paint (Graphics g) { int [][]W = new int[rows][cols]; int r, c; int shades=10; Color grays[] = new Color[shades+1]; for (int i=1; i<=shades; i++) grays[i] = new Color(256-i*25, 256-i*25, 256-i*25); /*new Color((int)(Math.random()*256), (int)(Math.random()*256), (int)(Math.random()*256)); */ g.setColor(Color.WHITE); g.fillRect(0,0, rows/height,cols/width); for (int i=0; i