draw Round Rect Fade - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

draw Round Rect Fade

Demo Code


//package com.java2s;
import java.awt.Color;

import java.awt.Graphics;

public class Main {
    public static void drawRoundRectFade(Graphics g, int x, int y,
            int width, int height, int arc1, int arc2, int fadeThickness) {
        Color c = g.getColor();//from  w ww  .  j  a  va2  s . c om
        int r = c.getRed();
        int gr = c.getGreen();
        int b = c.getBlue();
        for (int i = 0; i < fadeThickness; i += 1) {
            g.setColor(new Color(r, gr, b, (int) (255 - 255 * i
                    / fadeThickness)));
            g.drawRoundRect(x + i, y + i, width - 1 - 2 * i, height - 2 * i
                    - 1, arc1, arc2);
        }
    }
}

Related Tutorials