import java.awt.*; /** A class used to create Persian Rugs. **/ public class PersianRugMaker { private Color [] colors; private int [] [] rug; //indices into colors private int rugSize; private RugSpecs rgspcs; private int borderColor; /** Creates a PersianRugMaker. The sides will have length (2^x) + 1. A good value to try for x is 8. Initially, white will be the only color used. If you want to use more colors, you will have to use the addColor method before calling makeRug(). * @param x The exponent to use in determining the size * @param f The RugFunction to use in computing the colors **/ public PersianRugMaker(int x, RugSpecs rgspcs){ rugSize = (int) Math.pow(2, x) + 1; rug = new int[rugSize][rugSize]; borderColor = rgspcs.getBorderColor(); this.rgspcs = rgspcs; colors = new Color[rgspcs.colorListLength()]; for (int i = 0; i < rgspcs.colorListLength(); i++) colors[i] = rgspcs.getColor(i); } /** Creates a window with the rug in it using the given colors, size, and rug function. */ public void makeRug(){ Color [] [] cols = privMakeRug(); RugCanvas rc = new RugCanvas(cols); RugFrame rf = new RugFrame(rc); } private Color [] [] privMakeRug(){ for (int i = 0; i