Skip to: Site menu | Main content

Groovy 

      Download | Documentation | Developers | Community

An agile dynamic language for the Java Platform

GraphicsBuilder - Paints - Paint Add comment to Wiki View in Wiki Edit Wiki page Printable Version

Paint is a placeholder for other paints as gradients and textures. It allows setting new values on the wrapped paint, thus enabling paint reuse.

Properties

Property Default Notes
paint   must be a PaintProvider (all paints in GraphicsBuilder are PaintProviders)

Example

linearGradient( x1: 0, y1: 0, x2: 100, y2: 0, asPaint: true, id: 'g' ){
   stop( offset: 0, color: 'black' )
   stop( offset: 0.1, color: 'darkGreen' )
   stop( offset: 0.9, color: 'orange' )
   stop( offset: 1, color: 'black' )
}
rect( width: 100, height: 100, asShape: true, id: 'r1' )
rect( x: 110, width: 100, height: 100, asShape: true, id: 'r2' )
rect( y: 110, width: 210, height: 100, asShape: true, id: 'r3' )

// 3 rectangles as a single shape
add( borderColor: 'black', fill: g ) {
   shape( r1 )
   shape( r2 )
   shape( r3 )
}

// vertical rectangle
rect( x: 220, width: 80, height: 210 ){
   paint( g, x2: 0, y2: 50 )
}

// horizontal rectangle
rect( y: 220, width: 300, height: 50 ){
   paint( g, cycle: 'repeat' )
}