Stroking or Filling with a Texture

The buffered image used to create the TexturePaint object is scaled down/up to width w and height h. Conceptually, the scaled down/up buffered image is first painted at (x, y) in user space, and then replicated around it.
// See The Quintessential Drawing Program public void paint(Graphics g) { Graphics2D g2d = (Graphics2D)g; int x = 10; int y = 10; int width = 50; int height = 25; TexturePaint texture = new TexturePaint(bufferedImage, new Rectangle(x, y, width, height)); g2d.setPaint(texture); // Draw shapes...; see Drawing Simple Shapes }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.