...
Property | Default | Notes |
|---|---|---|
offset |
| a float value in the range [0..1] |
color |
| a Color or a color string |
Example
The following example takes advantage of paint reuse with paint4 rectangles, each one with a diagonal gradient
| Code Block |
|---|
linearGradient(def x1:stops 0,= y1:{ 0, x2: 100, y2: 0, asPaint: true, id: 'g' ){ def offsets = [0,0.5,1] def colors = ['black','red','blue'] (0..2).each{ stop( offset: 0offsets[it], color: 'black'colors[it] ) } stop } rect( offsetx: 0.1, colory: 'darkGreen' )0, width: 100, height: 100 ){ stop linearGradient( offsetx1: 0.9, colory1: 'orange' ) stop( offset: 1, color: 'black' ) } rect( 0, x2: 50, y2: 50 ){ stops() } } rect( x: 100, y: 0, width: 100, height: 100 ){ linearGradient( x1: 50, asShapey1: true0, idx2: 'r1' ) 0, y2: 50 ){ stops() } } rect( x: 1100, y: 100, width: 100, height: 100 ){ linearGradient( x1: 0, asShapey1: true50, idx2: 'r2' ) rect( y: 11050, y2: 0 ){ stops() } } rect( x: 100, y: 100, width: 210100, height: 100, asShape: true, id: 'r3' ) // 3 rectangles as a single shape add( borderColor: 'black', fill: g ) ){ linearGradient( x1: 50, y1: 50, x2: 0, y2: 0 ){ stops() } } |

Different settings for fit, stretch and cycle
| Code Block |
|---|
def stops = { shape( r1 )def offsets = shape( r2 )[0,0.5,1] def shape(colors 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' ) } |
= ['black','red','blue']
(0..2).each{ stop( offset: offsets[it], color: colors[it] ) }
}
inearGradient( x1: 0, y1: 0, x2: 50, y2: 50, id: 'g1' ){ stops() }
rect( x: 0, y: 0, width: 100, height: 100, fill: g1 )
circle( cx: 150, cy: 50, radius: 50, fill: g1 )
rect( x: 0, y: 100, width: 200, height: 100, fill: g1 )
|
| |
|
|
| |




