Class Drawing

java.lang.Object
org.openpatch.scratch.drawing.Drawing

public final class Drawing extends Object
What a DrawingSprite draws with in draw(Drawing): coordinates are the sprite's own, with (0, 0) at its position and y up; they turn, mirror and grow with the sprite. Only valid during that call.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clip(double x, double y, double width, double height)
    Draws only inside a rectangle until noClip(); a turned sprite clips to the rectangle around the turned one.
    void
    image(String path, double x, double y)
    An image at its own size, centred on a point.
    void
    image(String path, double x, double y, double width, double height)
    An image stretched to a size, centred on a point.
    int
     
    int
     
    void
    Draws everywhere again.
    void
    polygon(double[] x, double[] y, Color color)
    A filled polygon.
    void
    rectangle(double x, double y, double width, double height, Color color)
    A filled rectangle centred on a point.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • polygon

      public void polygon(double[] x, double[] y, Color color)
      A filled polygon.
      Parameters:
      x - x of every corner
      y - y of every corner
      color - the fill
    • rectangle

      public void rectangle(double x, double y, double width, double height, Color color)
      A filled rectangle centred on a point.
      Parameters:
      x - x of its centre
      y - y of its centre
      width - its width
      height - its height
      color - the fill
    • image

      public void image(String path, double x, double y)
      An image at its own size, centred on a point.
      Parameters:
      path - an image file or a built-in sprite name
      x - x of its centre
      y - y of its centre
    • image

      public void image(String path, double x, double y, double width, double height)
      An image stretched to a size, centred on a point.
      Parameters:
      path - an image file or a built-in sprite name
      x - x of its centre
      y - y of its centre
      width - the width
      height - the height
    • imageWidth

      public int imageWidth(String path)
      Parameters:
      path - an image file or a built-in sprite name
      Returns:
      its width in pixels
    • imageHeight

      public int imageHeight(String path)
      Parameters:
      path - an image file or a built-in sprite name
      Returns:
      its height in pixels
    • clip

      public void clip(double x, double y, double width, double height)
      Draws only inside a rectangle until noClip(); a turned sprite clips to the rectangle around the turned one.
      Parameters:
      x - x of its centre
      y - y of its centre
      width - its width
      height - its height
    • noClip

      public void noClip()
      Draws everywhere again.