Stroking or Filling with a Gradient Color

 

Color startColor = Color.red;

Color endColor = Color.blue;

// A non-cyclic gradient

GradientPaint gradient = new GradientPaint(

startX, startY, startColor,

endX, endY, endColor);

g2d.setPaint(gradient);

drawShape(g2d);

// A cyclic gradient

gradient = new GradientPaint(

startX, startY, startColor,

endX, endY, endColor, true);

g2d.setPaint(gradient);

drawShape(g2d);

你可能感兴趣的:(color)