
The process for drawing such a sphere as described in the book, requires 3 different paints applied one at a time over the same shape; the way paints currently work on GraphicsBuilder is pretty straight forward: set paint, fill shape, you are done. So how can 3 paints be applied over the same shape? the answer is
multiPaint
. MultiPaint is a group of paint operations, like gradientPaint
, radialGradient
and the other paints describe here. The code used to produce the previous image followsNotice that there is a
color
operation which serves a java.awt.Color factory depending on the properties you pass to it (default value for each unspecified color property is 0, 1 for alpha). Color has also been groovified with a derive
method that creates a copy of the target color and changes the specified color components. Lastly, radialGradient
now accepts transformations too, there are still some issues to be solved in terms of relative positions though (absolute=true
).Keep on Groovying!