This section illustrates you how to create round or radial gradient.
The radial gradient defines a color at a point, and blends into another color. We are providing you an example which displays the radial gradient. The RoundGradientPaint class describes the center of the gradient, radius and background color with the defined points and colors. The RoundGradientPaint class returns a RoundGradient from its createContext() method. The gradient blends color from the center point to the background color.
To translate a pixel value into color components and an alpha component, class ColorModel is used. The class AffineTransform provides transparency, scaling, rotation, shearing.
The getTransparency() method returns the translucent or opaque depending on the color specified that were passed to the constructor of the class RoundGradientPaint. The dispose() method is called when the PageContext is no longer needed.
To calculate the distance from the center point and iterates over each point in the ellipse, the getRaster() method is used. The class WritableRaster provide pixel writing capabilities.
Here is the code of RoundGradientPaintExample.java
Output will be displayed as:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Round gradient Paint Example
Post your Comment