Skip to content

Instantly share code, notes, and snippets.

@timyates
Last active December 11, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timyates/4529776 to your computer and use it in GitHub Desktop.
Save timyates/4529776 to your computer and use it in GitHub Desktop.
A GroovyFX version of the Canoo JavaFX Abacus tutorial part ii
@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 ->
e.source.translateX = MOVE_WAY
} )
}
}
}
}
}
@timyates
Copy link
Author

The original JavaFX tutorial can be found here: http://www.canoo.com/blog/2013/01/14/javafx-abacus-tutorial-part-ii/

@Dierk
Copy link

Dierk commented Jan 14, 2013

Cool, thanks!

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