Paint, Transparency
public class GradientPaint extends Object implements Paint
GradientPaint class provides a way to fill a Shape with a linear color gradient pattern. If Point P1 with Color C1 and Point P2 with Color C2 are specified in user space, the Color on the P1, P2 connecting line is proportionally changed from C1 to C2. Any point P not on the extended P1, P2 connecting line has the color of the point P' that is the perpendicular projection of P on the extended P1, P2 connecting line. Points on the extended line outside of the P1, P2 segment can be colored in one of two ways. Color C1 while points on the P2 side have the constant Color C2. BITMASK, OPAQUE, TRANSLUCENT
| Constructor | Description | 
|---|---|
| GradientPaint | Constructs a simple acyclic  GradientPaintobject. | 
| GradientPaint | Constructs either a cyclic or acyclic  GradientPaintobject depending on thebooleanparameter. | 
| GradientPaint | Constructs a simple acyclic  GradientPaintobject. | 
| GradientPaint | Constructs either a cyclic or acyclic  GradientPaintobject depending on thebooleanparameter. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| PaintContext | createContext | Creates and returns a  PaintContextused to generate a linear color gradient pattern. | 
| Color | getColor1() | Returns the color C1 anchored by the point P1. | 
| Color | getColor2() | Returns the color C2 anchored by the point P2. | 
| Point2D | getPoint1() | Returns a copy of the point P1 that anchors the first color. | 
| Point2D | getPoint2() | Returns a copy of the point P2 which anchors the second color. | 
| int | getTransparency() | Returns the transparency mode for this  GradientPaint. | 
| boolean | isCyclic() | Returns  trueif the gradient cycles repeatedly between the two colors C1 and C2. | 
public GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2)
GradientPaint object.x1 - x coordinate of the first specified Point in user spacey1 - y coordinate of the first specified Point in user spacecolor1 - Color at the first specified Point
x2 - x coordinate of the second specified Point in user spacey2 - y coordinate of the second specified Point in user spacecolor2 - Color at the second specified Point
NullPointerException - if either one of colors is nullpublic GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2)
GradientPaint object.pt1 - the first specified Point in user spacecolor1 - Color at the first specified Point
pt2 - the second specified Point in user spacecolor2 - Color at the second specified Point
NullPointerException - if either one of colors or points is nullpublic GradientPaint(float x1, float y1, Color color1, float x2, float y2, Color color2, boolean cyclic)
GradientPaint object depending on the boolean parameter.x1 - x coordinate of the first specified Point in user spacey1 - y coordinate of the first specified Point in user spacecolor1 - Color at the first specified Point
x2 - x coordinate of the second specified Point in user spacey2 - y coordinate of the second specified Point in user spacecolor2 - Color at the second specified Point
cyclic - true if the gradient pattern should cycle repeatedly between the two colors; false otherwise@ConstructorProperties({"point1","color1","point2","color2","cyclic"}) public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2, boolean cyclic) GradientPaint object depending on the boolean parameter.pt1 - the first specified Point in user spacecolor1 - Color at the first specified Point
pt2 - the second specified Point in user spacecolor2 - Color at the second specified Point
cyclic - true if the gradient pattern should cycle repeatedly between the two colors; false otherwiseNullPointerException - if either one of colors or points is nullpublic Point2D getPoint1()
Point2D object that is a copy of the point that anchors the first color of this GradientPaint.public Color getColor1()
Color object that is the color anchored by P1.public Point2D getPoint2()
Point2D object that is a copy of the point that anchors the second color of this GradientPaint.public Color getColor2()
Color object that is the color anchored by P2.public boolean isCyclic()
true if the gradient cycles repeatedly between the two colors C1 and C2.true if the gradient cycles repeatedly between the two colors; false otherwise.public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints)
PaintContext used to generate a linear color gradient pattern. See the specification of the method in the Paint interface for information on null parameter handling.createContext in interface Paint
cm - the preferred ColorModel which represents the most convenient format for the caller to receive the pixel data, or null if there is no preference.deviceBounds - the device space bounding box of the graphics primitive being rendered.userBounds - the user space bounding box of the graphics primitive being rendered.xform - the AffineTransform from user space into device space.hints - the set of hints that the context object can use to choose between rendering alternatives.PaintContext for generating color patterns.public int getTransparency()
GradientPaint.getTransparency in interface Transparency
GradientPaint object's transparency mode.
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/GradientPaint.html