Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created July 9, 2009 23:43
Show Gist options
  • Save aalmiray/144099 to your computer and use it in GitHub Desktop.
Save aalmiray/144099 to your computer and use it in GitHub Desktop.
import groovy.swing.SwingBuilder
import griffon.builder.gfx.*
import griffon.builder.gfx.swing.GfxPanel
import java.awt.Color
def gfx = new GfxBuilder()
def node = gfx.group() {
antialias true
background(color('white'))
(0..41).each{ i ->
def color = i % 5 == 0 ? color('red') : color('gray')
line(x1: 0, y1: i*10, x2: 410, y2: i*10, bc: color)
line(y1: 0, x1: i*10, y2: 410, x2: i*10, bc: color)
}
group(n:"g1"){
rect(n: '1', x: 50, y: 50, w: 100, h: 100) {
gradientPaint(color2: color('red'))
}
rect(n: '2', x: 50, y: 50, w: 100, h: 100, o: 0.8,
tx: 50) {
gradientPaint(color2: color('blue'))
}
rect(n: '3', x: 50, y: 50, w: 100, h: 100, o: 0.8,
ra: 45, ty: 50) {
gradientPaint(color2: color('green'))
}
rect(n: '4', x: 50, y: 50, w: 100, h: 100, o: 0.8,
ra: 45, sx: 2, sy: 2) {
gradientPaint(color2: color('yellow'))
}
rect(n: '5', x: 50, y: 50, w: 100, h: 100, o: 0.8,
ra: 45, sx: 0.5, sy: 0.5) {
gradientPaint(color2: color('violet'))
}
rect(n: '6', x: 50, y: 50, w: 100, h: 100, o: 0.8,
ra: 45, sx: 0.5, sy: 0.5, ty: 30) {
gradientPaint(color2: color('orange'))
}
}
}
def swing = new SwingBuilder()
swing.edt {
frame(title: "Sphere", size: [410,430], visible: true) {
panel(new GfxPanel(), id: "canvas", node: node)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment