In this section, you will studied the composition of color.
Composition is the process of combining two images. We are providing you an example. The Ellipse2D.Float class provides an ellipse defining values of float type.
Following code shows the slider:
|slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 65)|
A ChangeEvent class changed the state in the event source.
Following code shows the value for the slider.
|value = (float) (tempSlider.getValue()/ 100.0)|
The method Float.toString(value) converts the float value into String. The AlphaComposite provides the blending and transparency effects with graphics and images implementing the basic alpha compositing rules to combine source and destination. The image exists called destination and the image on being rendered on it is the source. Alpha Composite class adds another element to the composting rules i.e. the alpha value for the source and destination. The SRC_OVER is one of the rule, which is used when the destination image is opaque, the alpha applies a source image. An alpha value of 0.0f makes the source disappear and 1.0f make it completely opaque. The setStroke() method sets the stroke settings. We have defined four oval shapes oval1, oval2,oval3,oval4. The GradientPaint class fill a shape with a linear color gradient pattern.
Here is the code of ColorCompositeExample.java
If the alpha value is 0.3f, output will be:
If the alpha value is 0.88,output will be:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial