import java.awt.*; import java.applet.Applet; import java.util.*; public class SimplePictureWorld extends PictureWorld { public void initializePictureChoices() { // Define your pictures here and in auxiliary methods. // Add your pictures to the menu via "addPictureChoice(String name, Picture pic);" // Note: any method invocation "this.()" // can be abbreviated as "()" Picture redPatch = this.patch(Color.red); Picture bluePatch = this.patch(Color.blue); Picture greenWedge = this.wedge(Color.green); Picture mark = this.checkmark(Color.red, Color.blue); this.addPictureChoice("red patch", redPatch); this.addPictureChoice("blue patch", bluePatch); this.addPictureChoice("green wedge", greenWedge); this.addPictureChoice("mark", mark); // Below are some of the examples that we will study in class: /* addPictureChoice("wedgeFlipHorizontally", flipHorizontally(greenWedge)); addPictureChoice("wedgeFlipVertically", flipVertically(greenWedge)); addPictureChoice("wedgeFlipDiagonally", flipDiagonally(greenWedge)); addPictureChoice("wedgeClockwise90", clockwise90(greenWedge)); addPictureChoice("wedgeClockwise180", clockwise180(greenWedge)); addPictureChoice("wedgeClockwise270", clockwise270(greenWedge)); addPictureChoice("markFlipHorizontally", flipHorizontally(mark)); addPictureChoice("markFlipVertically", flipVertically(mark)); addPictureChoice("markFlipDiagonally", flipDiagonally(mark)); addPictureChoice("markClockwise90", clockwise90(mark)); addPictureChoice("markClockwise180", clockwise180(mark)); addPictureChoice("markClockwise270", clockwise270(mark)); */ /* addPictureChoice("wedgeAndMark", overlay(greenWedge, mark)); addPictureChoice("redBesideBlue", beside(redPatch, bluePatch)); addPictureChoice("redAboveBlue", above(redPatch, bluePatch)); addPictureChoice("redBesideBlue2", beside(redPatch, bluePatch, 0.75)); addPictureChoice("redAboveBlue2", above(redPatch, bluePatch, 0.75)); */ /* Picture chex = fourPics(redPatch, bluePatch, bluePatch, redPatch); addPictureChoice("Chex", chex); addPictureChoice("wedge4", fourSame(greenWedge)); addPictureChoice("mark4", fourSame(mark)); addPictureChoice("chex4", fourSame(chex)); addPictureChoice("wedgeRotate", rotations(greenWedge)); addPictureChoice("markRotate", rotations(mark)); addPictureChoice("chexRotate", rotations(chex)); */ /* addPictureChoice("wedgeTiling", tiling(greenWedge)); addPictureChoice("markTiling", tiling(mark)); addPictureChoice("chexTiling", tiling(chex)); */ /* addPictureChoice("wedgeWallpaper", wallpaper(greenWedge)); addPictureChoice("markWallpaper", wallpaper(mark)); addPictureChoice("markClockwise90Wallpaper", wallpaper(clockwise90(mark))); addPictureChoice("chexWallpaper", wallpaper(chex)); */ /* addPictureChoice("wedgeDesign", design(greenWedge)); addPictureChoice("markDesign", design(mark)); addPictureChoice("markClockwise90Design", design(clockwise90(mark))); addPictureChoice("chexDesign", design(chex)); */ } // Some helpful auxiliary methods that we will study in class today: public Picture fourPics (Picture p1, Picture p2, Picture p3, Picture p4) { return above(beside(p1,p2), beside(p3,p4)); } public Picture fourSame (Picture p) { return fourPics(p, p, p, p); } public Picture rotations (Picture p) { return fourPics(clockwise270(p), p, clockwise180(p), clockwise90(p)); } public Picture rotations2 (Picture p) { return rotations(clockwise90(p)); } public Picture rotations3 (Picture p) { return fourPics(p, clockwise90(p), clockwise180(p), clockwise270(p)); } public Picture tiling (Picture p) { return fourSame(fourSame(fourSame(fourSame(p)))); } public Picture wallpaper (Picture p) { return rotations(rotations(rotations(rotations(p)))); } public Picture design (Picture p) { return rotations3(rotations3(rotations3(rotations3(p)))); } // Below are methods for generating the pictures used above. // We will discuss these methods in class on Friday, October 2. public Picture patch (Color c) { return overlay (new Rect(0.0, 0.0, 1.0, 1.0, Color.black, false), new Rect(0.0, 0.0, 1.0, 1.0, c, true)); } public Picture wedge (Color c) { Poly w = new Poly(c, true); w.addPoint(0.0, 0.0); w.addPoint(0.5, 0.0); w.addPoint(0.5, 0.5); return w; } public Picture checkmark (Color c1, Color c2) { return overlay (new Line(0.0, 0.5, 0.5, 0.0, c1), new Line(0.5, 0.0, 1.0, 1.0, c2)); } }