public static void main(String[] args) {
   Picture p = new Picture(FileChooser.getMediaPath("horse.jpg"));
   Graphics g = p.getGraphics();
   Point ul = new Point(68, 24);
   Point te = new Point(182, 123);
   String message = "This is a test." + "  Of a message with more than one line in it.";
   SpeechBalloon balloon = new SpeechBalloon(ul, 200, te, message);
   balloon.draw(g);
   p.show();
 }
Пример #2
0
 public static void main(String[] args) {
   int width = Integer.parseInt(args[0]);
   int height = Integer.parseInt(args[1]);
   Picture pic = new Picture(width, height);
   int count = 0;
   for (int i = 0; i < height; i++) {
     for (int j = 0; j < width; j++) {
       pic.set(j, i, Color.RED);
       if (!BinaryStdIn.isEmpty()) {
         count++;
         boolean bit = BinaryStdIn.readBoolean();
         if (bit) pic.set(j, i, Color.BLACK);
         else pic.set(j, i, Color.WHITE);
       }
     }
   }
   pic.show();
   StdOut.println(count + " bits");
 }