Skip to content

Instantly share code, notes, and snippets.

@timyates
Last active December 11, 2015 10:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timyates/4585819 to your computer and use it in GitHub Desktop.
Save timyates/4585819 to your computer and use it in GitHub Desktop.
A GroovyFX version of the Canoo JavaFX Abacus tutorial part iii
@Grab('org.codehaus.groovyfx:groovyfx:0.3.1')
import static groovyx.javafx.GroovyFX.start
final int ROW_COUNT = 10
final int COL_COUNT = 10
final int RADIUS = 20
final int DIAMETER = 2 * RADIUS
final int WIDTH = COL_COUNT * DIAMETER
final int HEIGHT = ROW_COUNT * DIAMETER
final int MOVE_WAY = 100
start {
stage( title: 'GroovyFX Abacus', visible: true ) {
scene( width: WIDTH + MOVE_WAY, height: HEIGHT ) {
(0..<ROW_COUNT).each { int row ->
(0..<COL_COUNT).each { int column ->
circle( radius : RADIUS - 1,
centerX: RADIUS + ( column * DIAMETER ),
centerY: RADIUS + ( row * DIAMETER ),
onMouseClicked: { e ->
int newX = e.source.translateX > 1 ? 0 : MOVE_WAY
translateTransition( 200.ms, node:e.source, toX:newX ).playFromStart()
} )
}
}
}
}
}
@timyates
Copy link
Author

@Dierk
Copy link

Dierk commented Jan 21, 2013

added a back link. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment