Created
July 16, 2011 04:56
-
-
Save irof/1086016 to your computer and use it in GitHub Desktop.
GroovyFX ColorfulCircles #kancon2011
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
import javafx.animation.Timeline; | |
import javafx.scene.effect.BoxBlur | |
import javafx.scene.paint.Color; | |
import javafx.scene.shape.StrokeType; | |
import groovyx.javafx.GroovyFX; | |
import groovyx.javafx.SceneGraphBuilder; | |
import groovyx.javafx.TimelineBuilder; | |
GroovyFX.start {stage-> | |
def circles = [] | |
new SceneGraphBuilder(stage).stage(width: 1024, height: 768, visible: true) { | |
scene(fill: black){ | |
group(blendMode: 'overlay') { | |
group { | |
15.times{ | |
circles.add circle( | |
fill: Color.web("white", 0.15), | |
radius: 50, | |
strokeType: StrokeType.OUTSIDE, | |
stroke: Color.web("white", 0.45), | |
strokeWidth: 4, | |
translateX: Math.random() * stage.width, | |
translateY: Math.random() * stage.height, | |
){boxBlur(width: 10, height: 10, iterations: 3)} | |
} | |
} | |
rectangle(width: stage.width, height: stage.height, fill: black) | |
rectangle(width: stage.width, height: stage.height, fill: linearGradient(stops: [ | |
[0, Color.web("#f8db55")], [0.14, Color.web("#c0fe56")], | |
[0.28, Color.web("#5dfbc1")], [0.43, Color.web("#64c2f8")], | |
[0.57, Color.web("#be4af7")], [0.71, Color.web("#ed5fc2")], | |
[0.85, Color.web("#ef504c")], [1, Color.web("#f2660f")] | |
])) | |
} | |
} | |
} | |
new TimelineBuilder().timeline(cycleCount: Timeline.INDEFINITE, autoReverse: true) { | |
circles.each {circle -> | |
at (6000.ms){ | |
change(circle, 'translateX') {to Math.random() * stage.width} | |
change(circle, 'translateY') {to Math.random() * stage.height} | |
change(circle, 'radius') { to Math.random() * 300} | |
} | |
} | |
}.play() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment