Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created July 28, 2009 19:09
Show Gist options
  • Save aalmiray/157607 to your computer and use it in GitHub Desktop.
Save aalmiray/157607 to your computer and use it in GitHub Desktop.
import groovy.swing.SwingBuilder
import griffon.builder.trident.*
import griffon.builder.gfx.*
import griffon.builder.gfx.swing.*
import groovy.beans.Bindable
import org.pushingpixels.trident.Timeline.TimelineState
@Bindable
class Model {
float s = 0.5f
float ra = 0.0f
}
def model = new Model()
def trident = new TridentBuilder()
def anim = trident.timeline(model, duration: 3000, loop: 'reverse') {
interpolatedProperty(property: "s", from: 0.5f, to: 2.0f)
interpolatedProperty(property: "ra", from: 0f, to: 359f)
}
def cx = 100
def cy = 100
def radius = 25
def gfx = new GfxBuilder()
def node = gfx.group {
antialias true
background(color: color("white"))
group(sx: bind{model.s}, sy: bind{model.s}, ra: bind{model.ra},
mouseClicked: {anim.state == TimelineState.SUSPENDED? anim.resume() : anim.suspend()}) {
rect(x: cx-radius, y: cy-radius, w: radius*2, h: radius*2, f: color('blue'))
circle(cx: cx-radius, cy: cy-radius, r: radius/2, f: color('red'))
circle(cx: cx-radius, cy: cy+radius, r: radius/2, f: color('green'))
circle(cx: cx+radius, cy: cy-radius, r: radius/2, f: color('yellow'))
circle(cx: cx+radius, cy: cy+radius, r: radius/2, f: color('violet'))
}
}
def swing = new SwingBuilder()
swing.edt {
frame(title: "GFX + Trident", size: [210,220], visible: true) {
widget(new GfxCanvas(), id: "canvas", node: node)
}
}
trident.swingRepaintTimeline(swing.canvas, loop: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment