src/main/java/org/teachingextensions/logo/utils/MazeUtils/StdDraw.java
public static void picture(double x, double y, String filename, double scaledWidth, double scaledHeight,
      double degrees)
  {
    if (scaledWidth < 0)
      throw new IllegalArgumentException("width is negative: " + scaledWidth);
    if (scaledHeight < 0)
      throw new IllegalArgumentException("height is negative: " + scaledHeight);
    Image image = getImageFromFile(filename);
    double xs = scaleX(x);
    double ys = scaleY(y);
    double ws = factorX(scaledWidth);
    double hs = factorY(scaledHeight);
    if (ws < 0 || hs < 0)
      throw new IllegalArgumentException("image " + filename + " is corrupt");
    if (ws <= 1 && hs <= 1)
      pixel(x, y);
    offscreen.rotate(Math.toRadians(-degrees), xs, ys);
    offscreen.drawImage(image, (int) Math.round(xs - ws / 2.0), (int) Math.round(ys - hs / 2.0),
        (int) Math.round(ws), (int) Math.round(hs), null);
    offscreen.rotate(Math.toRadians(+degrees), xs, ys);
    draw();
  }
public static void picture(double x, double y, String filename, double scaledWidth, double scaledHeight,
      double degrees)
  {
    if (scaledWidth < 0)
      throw new IllegalArgumentException("width is negative: " + scaledWidth);
    if (scaledHeight < 0)
      throw new IllegalArgumentException("height is negative: " + scaledHeight);
    Image image = getImageFromFile(filename);
    double xs = scaleX(x);
    double ys = scaleY(y);
    double ws = factorX(scaledWidth);
    double hs = factorY(scaledHeight);
    if (ws < 0 || hs < 0)
      throw new IllegalArgumentException("image " + filename + " is corrupt");
    if (ws <= 1 && hs <= 1)
      pixel(x, y);
    offscreen.rotate(Math.toRadians(-degrees), xs, ys);
    offscreen.drawImage(image, (int) Math.round(xs - ws / 2.0), (int) Math.round(ys - hs / 2.0),
        (int) Math.round(ws), (int) Math.round(hs), null);
    offscreen.rotate(Math.toRadians(+degrees), xs, ys);
    draw();
  }
Draws the specified image centered at (<em>x</em>, <em>y</em>), rotated
given number of degrees, and rescaled to the specified bounding box.
The supported image formats are JPEG, PNG, and GIF.

@param  x the center <em>x</em>-coordinate of the image
@param  y the center <em>y</em>-coordinate of the image
@param  filename the name of the image/picture, e.g., "ball.gif"
@param  scaledWidth the width of the scaled image in pixels
@param  scaledHeight the height of the scaled image in pixels
@param  degrees is the number of degrees to rotate counterclockwise
@throws IllegalArgumentException if either {@code scaledWidth}
or {@code scaledHeight} is negative
@throws IllegalArgumentException if the image filename is invalid