Example usage for java.awt AlphaComposite DST_ATOP

List of usage examples for java.awt AlphaComposite DST_ATOP

Introduction

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

Prototype

int DST_ATOP

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

Click Source Link

Document

The part of the destination lying inside of the source is composited over the source and replaces the destination (Porter-Duff Destination Atop Source rule).

Usage

From source file:CompositingDST_ATOP.java

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

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

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

    gbi.setPaint(Color.red);//from w ww .  j  a v a2 s  . 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);
}