Example usage for java.awt AlphaComposite DST

List of usage examples for java.awt AlphaComposite DST

Introduction

In this page you can find the example usage for java.awt AlphaComposite DST.

Prototype

int DST

To view the source code for java.awt AlphaComposite DST.

Click Source Link

Document

The destination is left untouched (Porter-Duff Destination rule).

Usage

From source file:CompositingDST.java

public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;

    AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.DST, 0.5f);

    BufferedImage buffImg = new BufferedImage(60, 60, BufferedImage.TYPE_INT_ARGB);
    Graphics2D gbi = buffImg.createGraphics();

    gbi.setPaint(Color.red);//from  w w  w . j a  v  a  2s  .c  o m
    gbi.fillRect(0, 0, 40, 40);
    gbi.setComposite(ac);

    gbi.setPaint(Color.green);
    gbi.fillRect(5, 5, 40, 40);

    g2d.drawImage(buffImg, 20, 20, null);
}