Andres is a DZone Zone Leader and has posted 143 posts at DZone. You can read more from them at their website. View Full User Profile

GraphicsBuilder Tutorial III: Paints & Colors

02.26.2008
| 20261 views |
  • submit to reddit

Border Paints

Colors can be applied to borders but paints can be too, as a matter of fact you can assign any paint you want to, just make sure you nest them in a borderPaint node. the following example shows as series of rectangles with a borderWidth > 1 with a flat color paint and gradient paints

rect( x: 0, y: 0, width: 220, height: 220, fill: 'white' )
rect( x: 20, y: 20, width: 180, height: 180, borderWidth: 10 ){
borderPaint {
colorPaint( 'blue' )
}
}
rect( x: 40, y: 40, width: 140, height: 140, borderWidth: 10 ){
borderPaint {
gradientPaint( color2: 'blue' )
}
}
rect( x: 60, y: 60, width: 100, height: 100, borderWidth: 10 ){
borderPaint {
linearGradient( x1: 50, x2: 0, id: 'g' ) {
stop( offset: 0, color: 'red' )
stop( offset: 0.33, color: 'orange' )
stop( offset: 0.66, color: 'darkGreen' )
stop( offset: 1, color: 'blue' )
}
}
}
rect( x: 85, y: 85, width: 50, height: 50, borderWidth: 20 ){
borderPaint {
radialGradient( cx: 25, cy: 25, radius: 50, linkTo: g )
}
}

You should be able to apply any of the previous paint settings to borders.

Published at DZone with permission of its author, Andres Almiray.