src/main/java/org/teachingextensions/logo/utils/MazeUtils/StdDraw.java
public static void square(double x, double y, double halfLength)
  {
    if (!(halfLength >= 0))
      throw new IllegalArgumentException("half length must be nonnegative");
    double xs = scaleX(x);
    double ys = scaleY(y);
    double ws = factorX(2 * halfLength);
    double hs = factorY(2 * halfLength);
    if (ws <= 1 && hs <= 1)
      pixel(x, y);
    else
      offscreen.draw(new Rectangle2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
    draw();
  }
public static void square(double x, double y, double halfLength)
  {
    if (!(halfLength >= 0))
      throw new IllegalArgumentException("half length must be nonnegative");
    double xs = scaleX(x);
    double ys = scaleY(y);
    double ws = factorX(2 * halfLength);
    double hs = factorY(2 * halfLength);
    if (ws <= 1 && hs <= 1)
      pixel(x, y);
    else
      offscreen.draw(new Rectangle2D.Double(xs - ws / 2, ys - hs / 2, ws, hs));
    draw();
  }
Draws a square of side length 2r, centered at (<em>x</em>, <em>y</em>).

@param  x the <em>x</em>-coordinate of the center of the square
@param  y the <em>y</em>-coordinate of the center of the square
@param  halfLength one half the length of any side of the square
@throws IllegalArgumentException if {@code halfLength} is negative