Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created July 27, 2009 23:05
Show Gist options
  • Save aalmiray/156812 to your computer and use it in GitHub Desktop.
Save aalmiray/156812 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
@Bindable
class Model {
float s = 0.5f
float ra = 0.0f
}
def model = new Model()
def gfx = new GfxBuilder()
def node = gfx.group {
antialias true
rect(id: "r", x: 75, y: 75, w: 50, h: 50, f: color('blue'),
sx: bind{model.s}, sy: bind{model.s}, ra: bind{model.ra})
}
def swing = new SwingBuilder()
swing.edt {
frame(size: [210,220], visible: true) {
widget(new GfxCanvas(), id: "canvas", node: node)
}
}
def trident = new TridentBuilder()
trident.with {
timeline(model, duration: 2000, loop: 'reverse') {
interpolatedProperty(property: "s", from: 0.5f, to: 2.0f)
interpolatedProperty(property: "ra", from: 0f, to: 359f)
}
swingRepaintTimeline(swing.canvas, loop: true)
}
/*
int direction = 1
trident.swingRepaintTimeline(swing.canvas, loop: true)
trident.timeline(duration: 2000) {
timelineCallback {
timelinePulse { df, tp ->
model.s += direction * 0.1
if(model.s >= 2.0) direction = -1
else if(model.s <= 0.5) direction = 1
}
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment