Exemple #1
0
  /** Test client. */
  public static void main(String[] args) {

    // set the scale of the coordinate system
    StdDraw.setXscale(0, 10);
    StdDraw.setYscale(0, 10);

    // Draw line
    StdDraw.line(1, 1, 8, 8);

    // Draw square
    StdDraw.setPenColor(StdDraw.RED);
    StdDraw.setPenRadius(.01);
    StdDraw.square(3, 3, 2);

    // Draw filled Square
    StdDraw.setPenColor(StdDraw.BLUE);
    StdDraw.filledSquare(5, 8, 2);

    // Draw Circle
    StdDraw.setPenColor(StdDraw.BLACK);
    StdDraw.setPenRadius();
    StdDraw.circle(5, 5, 2);

    // text
    StdDraw.setPenColor(StdDraw.BLACK);
    StdDraw.text(6, 1, "black text");
  }
Exemple #2
0
  /** Test client. */
  public static void main(String[] args) {
    StdDraw.square(.2, .8, .1);
    StdDraw.filledSquare(.8, .8, .2);
    StdDraw.circle(.8, .2, .2);

    StdDraw.setPenColor(StdDraw.BOOK_RED);
    StdDraw.setPenRadius(.02);
    StdDraw.arc(.8, .2, .1, 200, 45);

    // draw a blue diamond
    StdDraw.setPenRadius();
    StdDraw.setPenColor(StdDraw.BOOK_BLUE);
    double[] x = {.1, .2, .3, .2};
    double[] y = {.2, .3, .2, .1};
    StdDraw.filledPolygon(x, y);

    // text
    StdDraw.setPenColor(StdDraw.BLACK);
    StdDraw.text(0.2, 0.5, "black text");
    StdDraw.setPenColor(StdDraw.WHITE);
    StdDraw.text(0.8, 0.8, "white text");
  }