Class Java2DExamples

java.lang.Object
net.jrodolfo.java_evolution.java02.java2d.Java2DExamples

public class Java2DExamples extends Object
Demonstrates Java 2D rendering to an in-memory image.
  • Constructor Details

    • Java2DExamples

      public Java2DExamples()
  • Method Details

    • blankImage

      public BufferedImage blankImage(int width, int height)
      Creates a blank image that can be drawn without opening a GUI window.
      Parameters:
      width - image width
      height - image height
      Returns:
      blank image
    • drawFilledRectangle

      public BufferedImage drawFilledRectangle()
      Draws a filled rectangle into an in-memory image.
      Returns:
      image with a red rectangle
    • drawOutlinedEllipse

      public BufferedImage drawOutlinedEllipse()
      Draws an outlined ellipse using Java 2D shape and stroke APIs.
      Returns:
      image with a blue ellipse outline
    • pixelColor

      public Color pixelColor(BufferedImage image, int x, int y)
      Reads the color written to a pixel.
      Parameters:
      image - image to inspect
      x - x coordinate
      y - y coordinate
      Returns:
      pixel color including alpha