开发者

How to draw shapes with color gradients and different opacities?

开发者 https://www.devze.com 2023-04-12 03:41 出处:网络
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 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

精彩评论

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

关注公众号