gradientPaint and linearGradient/radialGradient I felt that something was not quite right when specifying stretch and/or fit in a paint that was going to be reused later in several shapes, something had to change.The good news is that those properties are still in the same place (albeit
gradientPaint.cyclic changed to gradientPaint.cycle), the better news is that now exists a generic placeholder for paints, aptly named paint, which serves as a proxy for the wrapped paint, in the same manner shape works for Shapes inside area operations. But this wrapper allows the wrapped element to be changed because it actually clones the original Paint (shape does not allow it, I'm thinking that may change too). Here is a simple example of paint and shape, 3 rectangles are merged into a single Shape thanks to Area.add, then a previously defined paint is applied using paint, then a 4th rectangle is drawn and filled with the same paint but it changes the orientation of the gradient, finally a 5th rectangle is drawn filled with the same paint again, this time changing the cycle mode
This is the code used to create the drawing
Using
asPaint=true on Paints has the same effect as asShape=true for Shapes, it means it will not execute the operation, this case setting a Paint on the java.awt.Graphics object, but creates a PaintProvider operation that can be later referenced (thanks to its id property). Note that instead of specifying a fill on Area.add we could also have used paint, with the same result.The last stop on painting options for GraphicsBuilder will be
texturePaint and because it relies on images image will be back as well.Keep on Groovying!