The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt  [78 examples] > Drawing  [7 examples]

e580. 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 e575 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 e586 Drawing Simple Shapes
    }

 Related Examples
e575. The Quintessential Drawing Program
e576. Drawing with Alpha
e577. Enabling Antialiasing
e578. Setting the Clipping Area with a Shape
e579. Changing the Thickness of the Stroking Pen
e581. Animating an Array of Images in an Application

See also: Colors    Components    Containers    Cursors    Events    Focus    Frames    GridBagLayout    Images    Shapes    Simulating Events    Text    The Screen   


© 2002 Addison-Wesley.