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!
- Use the two
Color
objects (constructed using the 4int
form) for theGradientPaint
. - Set that paint to the
Graphics
obtained from an image declared to support transparency (e.g.TYPE_INT_ARGB
). - Paint (probably using one of the 'fill' methods).
精彩评论