Last active
December 11, 2015 10:19
-
-
Save timyates/4585819 to your computer and use it in GitHub Desktop.
A GroovyFX version of the Canoo JavaFX Abacus tutorial part iii
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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() | |
} ) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original JavaFX tutorial here http://www.canoo.com/blog/2013/01/21/javafx-abacus-tutorial-part-iii/