Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created July 11, 2009 02:50
Show Gist options
  • Save aalmiray/145047 to your computer and use it in GitHub Desktop.
Save aalmiray/145047 to your computer and use it in GitHub Desktop.
import org.pushingpixels.trident.Timeline.RepeatBehavior
application(title:'snake',
size:[400,220],
locationByPlatform:true,
iconImage: imageIcon('/griffon-icon-48x48.png').image,
iconImages: [imageIcon('/griffon-icon-48x48.png').image,
imageIcon('/griffon-icon-32x32.png').image,
imageIcon('/griffon-icon-16x16.png').image]) {
delegate.registerFactory("gfxpanel", new GfxPanelFactory())
gfxpanel(id: "canvas", preferredSize: [400,200], animate: false) {
group(borderColor: "none", fill: color("black")) {
(0..<20).each { i ->
(0..<10).each { j ->
def rect = rect(x: i*20, y: j*20, w: 20, h: 20)
rect.props.timeline = timeline(rect, duration: 2500) {
interpolatedProperty("fill", from: color("yellow"), to: color("black"))
}
rect.props.rollover = false
rect.mouseExited = {rect.props.rollover = false}
rect.mouseEntered = {
if(rect.props.rollover) return
rect.props.rollover = true
rect.props.timeline.replay()
}
}
}
}
}
swingRepaintTimeline(canvas).playLoop(RepeatBehavior.LOOP)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment