Class ConicalGradientPaint
java.lang.Object
org.pushingpixels.radiance.theming.internal.utils.ConicalGradientPaint
- All Implemented Interfaces:
Paint, Transparency
A paint class that creates conical gradients around a given center point
It could be used in the same way as LinearGradientPaint and RadialGradientPaint
and follows the same syntax.
You could use floats from 0.0 to 1.0 for the fractions which is standard but it's
also possible to use angles from 0.0 to 360 degrees which is most of the times
much easier to handle.
Gradients always start at the top with a clockwise direction and you could
rotate the gradient around the center by given offset.
The offset could also be defined from -0.5 to +0.5 or -180 to +180 degrees.
If you would like to use degrees instead of values from 0 to 1 you have to use
the full constructor and set the USE_DEGREES variable to true.
Contributed under the BSD license by Gerrit Grunwald. Original code from
https://www.jug-muenster.de/java2d-conical-gradient-paint-674/
- Author:
- hansolo
-
Field Summary
Fields inherited from interface Transparency
BITMASK, OPAQUE, TRANSLUCENT -
Constructor Summary
ConstructorsConstructorDescriptionConicalGradientPaint(boolean USE_DEGREES, Point2D CENTER, float GIVEN_OFFSET, float[] GIVEN_FRACTIONS, Color[] GIVEN_COLORS) ConicalGradientPaint(Point2D CENTER, float[] GIVEN_FRACTIONS, Color[] GIVEN_COLORS) -
Method Summary
Modifier and TypeMethodDescriptioncreateContext(ColorModel COLOR_MODEL, Rectangle DEVICE_BOUNDS, Rectangle2D USER_BOUNDS, AffineTransform TRANSFORM, RenderingHints HINTS) getColorFromFraction(Color START_COLOR, Color DESTINATION_COLOR, int RANGE, int VALUE) With the START_COLOR at the beginning and the DESTINATION_COLOR at the end of the given RANGE the method will calculate and return the color that equals the given VALUE. e.g. a START_COLOR of BLACK (R:0, G:0, B:0, A:255) and a DESTINATION_COLOR of WHITE(R:255, G:255, B:255, A:255) with a given RANGE of 100 and a given VALUE of 50 will return the color that is exactly in the middle of the gradient between black and white which is gray(R:128, G:128, B:128, A:255) So this method is really useful to calculate colors in gradients between two given colors.int
-
Constructor Details
-
ConicalGradientPaint
public ConicalGradientPaint(Point2D CENTER, float[] GIVEN_FRACTIONS, Color[] GIVEN_COLORS) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
ConicalGradientPaint
public ConicalGradientPaint(boolean USE_DEGREES, Point2D CENTER, float GIVEN_OFFSET, float[] GIVEN_FRACTIONS, Color[] GIVEN_COLORS) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
-
Method Details
-
getColorFromFraction
With the START_COLOR at the beginning and the DESTINATION_COLOR at the end of the given RANGE the method will calculate and return the color that equals the given VALUE. e.g. a START_COLOR of BLACK (R:0, G:0, B:0, A:255) and a DESTINATION_COLOR of WHITE(R:255, G:255, B:255, A:255) with a given RANGE of 100 and a given VALUE of 50 will return the color that is exactly in the middle of the gradient between black and white which is gray(R:128, G:128, B:128, A:255) So this method is really useful to calculate colors in gradients between two given colors.- Parameters:
START_COLOR-DESTINATION_COLOR-RANGE-VALUE-- Returns:
-
createContext
public PaintContext createContext(ColorModel COLOR_MODEL, Rectangle DEVICE_BOUNDS, Rectangle2D USER_BOUNDS, AffineTransform TRANSFORM, RenderingHints HINTS) - Specified by:
createContextin interfacePaint
-
getTransparency
public int getTransparency()- Specified by:
getTransparencyin interfaceTransparency
-