Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created May 29, 2010 21:53
Show Gist options
  • Save aalmiray/418578 to your computer and use it in GitHub Desktop.
Save aalmiray/418578 to your computer and use it in GitHub Desktop.
import griffon.effects.*
import java.awt.Point
import java.awt.Dimension
opacity = { Map args ->
Effects.opacity(args, window) { win, params ->
println "Window title is ${win.title}"
}
}
move = { Map args -> Effects.move(args, window) }
resize = { Map args -> Effects.resize(args, window) }
bounds = { Map args -> Effects.bounds(args, window) }
shake = { Map args -> Effects.shake(args, window) }
scale = { Map args -> Effects.scale(args, window) }
fade = { Map args -> Effects.fade(args, window){ w, a -> Effects.appear(a, w) } }
puff = { Map args ->
Point o = window.location
Dimension s = window.getSize()
Effects.puff(args, window){ w , a ->
Effects.chain([
new Bounds(x: o.x, y: o.y, w: s.width, h: s.height, mode: 'absolute', w),
new Appear(w)
])
}
}
chain = {
Effects.chain([
new Shake(distance: 10i, window),
new Move(x: 200i, y: 200i, window),
new Opacity(from: 1.0f, to: 0.5f, window),
new Resize(w: 200i, h: 200i, mode: 'absolute', window),
new Opacity(from: 0.5f, to: 1.0f, window),
new Shake(distance: 10i, window, { w, p -> println "Shake!"})
]) { w, p -> println "Chain!" }
}
dropout = {
Point origin = window.location
Effects.dropOut(window, anchor: Anchor.LEFT) { w, p ->
Effects.appear([:], w)
Effects.move(w, x: origin.x, y: origin.y, mode: 'absolute')
}
}
application(title: 'Effects Demo', id: 'window', undecorated: true,
size:[480,600],
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]) {
gridLayout(cols: 4, rows: 7)
button('Fade Out', actionPerformed: {opacity from: 1.0f, to: 0.5f})
button('Fade In', actionPerformed: {opacity from: 0.5f, to: 1.0f})
button('Chain!', actionPerformed: chain)
button('Shake!', actionPerformed: {shake distance: 10i, duration: 250i})
button('Move[R] (+100, +50)', actionPerformed: {move x: 100i, y: 50i})
button('Move[R] (-100, -50)', actionPerformed: {move x: -100i, y: -50i})
button('Move[A] (+100, +50)', actionPerformed: {move x: 100i, y: 50i, mode: 'absolute'})
button('Move[A] (-100, -50)', actionPerformed: {move x: -100i, y: -50i, mode: 'absolute'})
button('Resize[R] (+50, +50)', actionPerformed: {resize w: 50i, h: 50i})
button('Resize[R] (-50, -50)', actionPerformed: {resize w: -50i, h: -50i})
button('Resize[A] (+200, +200)', actionPerformed: {resize w: 200i, h: 200i, mode: 'absolute'})
button('Resize[A] (320, 240)', actionPerformed: {resize w: 320i, h: 240i, mode: 'absolute'})
button('Bounds[R] (+100, +50, +50, +50)', actionPerformed: {bounds x: 100i, y: 50i, w: 50i, h: 50i})
button('Bounds[R] (-100, -50, -50, -50)', actionPerformed: {bounds x: -100i, y: -50i, w: -50i, h: -50i})
button('Bounds[A] (+100, +50, +200, +200)', actionPerformed: {bounds x: 100i, y: 50i, w: 200i, h: 200i, mode: 'absolute'})
button('Bounds[A] (0, 0, 320, 480)', actionPerformed: {bounds w: 320i, h: 480i, mode: 'absolute'})
button('Scale TL', actionPerformed: {scale from: 0, to: 100, anchor: 'top left'})
button('Scale T', actionPerformed: {scale from: 0, to: 100, anchor: 'top'})
button('Scale TR', actionPerformed: {scale from: 0, to: 100, anchor: 'top right'})
button('Fade', actionPerformed: {fade [:]})
button('Scale L', actionPerformed: {scale from: 0, to: 100, anchor: 'left'})
button('Scale C', actionPerformed: {scale from: 0, to: 100, anchor: 'center'})
button('Scale R', actionPerformed: {scale from: 0, to: 100, anchor: 'right'})
button('Puff', actionPerformed: {puff duration: 300l})
button('Scale BL', actionPerformed: {scale from: 0, to: 100, anchor: 'bottom left', scaleY: false})
button('Scale B', actionPerformed: {scale from: 0, to: 100, anchor: 'bottom'})
button('Scale BR', actionPerformed: {scale from: 0, to: 100, anchor: 'bottom right'})
button('Drop out', actionPerformed: dropout)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment