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.
Paint
,
Graphics2D.setPaint(java.awt.Paint)
BITMASK, OPAQUE, TRANSLUCENT
Constructor | Description |
---|---|
GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2) |
Constructs a simple acyclic
GradientPaint object. |
GradientPaint(float x1,
float y1,
Color color1,
float x2,
float y2,
Color color2,
boolean cyclic) |
Constructs either a cyclic or acyclic
GradientPaint
object depending on the boolean parameter. |
GradientPaint(Point2D pt1,
Color color1,
Point2D pt2,
Color color2) |
Constructs a simple acyclic
GradientPaint object. |
GradientPaint(Point2D pt1,
Color color1,
Point2D pt2,
Color color2,
boolean cyclic) |
Constructs either a cyclic or acyclic
GradientPaint
object depending on the boolean parameter. |
Modifier and Type | Method | Description |
---|---|---|
PaintContext |
createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform xform,
RenderingHints hints) |
Creates and returns a
PaintContext used 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
true if the gradient cycles repeatedly
between the two colors C1 and C2. |