1 /* 2 * Paint a picture with dots. 3 */ 4 5 package npw; 6 7 import java.awt.Color; 8 import javax.swing.SwingUtilities; 9 import painter.SPainter; 10 import shapes.SCircle; 11 12 public class Dots { 13 14 private void paintTheImage() { 15 SPainter painter = new SPainter("Dots",600,600); 16 SCircle eyes = new SCircle(100); 17 SCircle mouth1 = new SCircle(35); 18 SCircle mouth2 = new SCircle(40); 19 SCircle mouth3 = new SCircle(45); 20 paintEyes(painter, eyes); 21 paintMouth1(painter, mouth1); 22 paintMouth2(painter, mouth2); 23 paintMouth3(painter, mouth3); 24 } 25 26 private void paintMouth1(SPainter painter, SCircle mouth1) { 27 painter.setColor(Color.PINK); 28 painter.mbk(100); 29 painter.mlt(225); 30 painter.paint(mouth1); 31 painter.mrt(450); 32 painter.paint(mouth1); 33 painter.mlt(225); 34 painter.mfd(100); 35 } 36 37 private void paintMouth2(SPainter painter, SCircle mouth2) { 38 painter.setColor(Color.GREEN); 39 painter.mbk(125); 40 painter.mlt(150); 41 painter.paint(mouth2); 42 painter.mrt(300); 43 painter.paint(mouth2); 44 painter.mlt(150); 45 painter.mfd(125); 46 painter.mbk(230); 47 painter.paint(mouth2); 48 painter.mfd(230); 49 } 50 51 private void paintMouth3(SPainter painter, SCircle mouth3) { 52 painter.setColor(Color.RED); 53 painter.mbk(150); 54 painter.mlt(50); 55 painter.paint(mouth3); 56 painter.mrt(100); 57 painter.paint(mouth3); 58 painter.mlt(50); 59 painter.mfd(150); 60 } 61 62 private void paintEyes(SPainter painter, SCircle eyes) { 63 painter.setColor(Color.BLUE); 64 painter.mfd(150); 65 painter.mlt(150); 66 painter.paint(eyes); 67 painter.mrt(300); 68 painter.paint(eyes); 69 painter.mlt(150); 70 painter.mbk(150); 71 } 72 73 public Dots() { 74 paintTheImage(); 75 } 76 77 public static void main(String[] args) { 78 SwingUtilities.invokeLater(new Runnable() { 79 public void run() { 80 new Dots(); 81 } 82 }); 83 } 84 } 85 86