开发者

How to draw shapes with color gradients and different opacities?

I have used transparency to paint shapes using Graphics.drawXXX methods but they always were solid colors, and now I need something a开发者_C百科 bit different:

I need to draw a shape on my component with a color gradient that goes from an absolutely opaque black color to an absolutely transparent black color.

How can I do this? Thank you!


  1. Use the two Color objects (constructed using the 4 int form) for the GradientPaint.
  2. Set that paint to the Graphics obtained from an image declared to support transparency (e.g. TYPE_INT_ARGB).
  3. Paint (probably using one of the 'fill' methods).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜