Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

MultiPaints allow several paints to be applied to the same shape.

Example

The following example is taken from chapter 7 of Filthy Rich Clients where 3 gradients are applied to a circle in order to create the illusion of a sphere

Code Block
def width = 200
def height = 200
renderingHint( key: 'antialiasing', value: 'antialias on' )
circle( cx: width/2, cy: height/2, radius: width/2, borderColor: false ){
   multiPaint {
      radialGradient( cx: width/2, cy: height/2, radius: width/2 ) {
         stop( offset: 0, color: color(red: 6, green: 76, blue: 160, alpha: 127) )
         stop( offset: 1, color: color(alpha: 204) )
      }
      def lighting = color(red: 64, green: 142, blue: 203, alpha: 255)
      radialGradient( cx: width/2, cy: height*1.5,
                      fx: width/2, fy: (height*1.75)+6,
                      radius: width/2 ) {
         stop( offset: 0, color: lighting )
         stop( offset: 0.8, color: lighting.derive(alpha:0) )
         transformations{ scale(y:0.5) }
      }
      radialGradient( cx: width/2, cy: height/2,
                      fx: 45, fy: 25, radius: width/1.4 ){
         stop( offset: 0, color: color('white').derive(alpha:0.4) )
         stop( offset: 0.5, color: color('white').derive(alpha:0) )
      }
   }
}