Skip to content

Instantly share code, notes, and snippets.

@rmloveland
Created June 13, 2020 00:54
Show Gist options
  • Save rmloveland/593768f9c651739ff9d64849da28a853 to your computer and use it in GitHub Desktop.
Save rmloveland/593768f9c651739ff9d64849da28a853 to your computer and use it in GitHub Desktop.
(module-extends javafx.application.Application)
(import (class javafx.application Application)
(class javafx.scene Group Scene)
(class javafx.stage Stage)
(class javafx.animation FillTransition)
(class javafx.animation Timeline)
(class javafx.animation ParallelTransition)
(class javafx.animation RotateTransition)
(class javafx.animation ScaleTransition)
(class javafx.animation TranslateTransition)
(class javafx.util Duration)
(class javafx.scene.paint Color)
(class javafx.scene.shape Rectangle))
(define (start (stage ::Stage))
(let* ((root (Group))
(scene (Scene root 500 500 Color:BLACK))
(r (Rectangle 25 25 250 250))
(children (root:getChildren))
(duration (Duration:millis 750))
(translate (TranslateTransition duration))
(fill (FillTransition duration))
(rotate (RotateTransition duration))
(scale (ScaleTransition duration))
(transition (ParallelTransition r translate fill rotate scale)))
;; Add a (blue) rectangle to scene graph
(r:setFill Color:BLUE)
(children:add r)
(translate:setToX 390)
(translate:setToY 390)
(fill:setToValue Color:RED)
(rotate:setToAngle 360)
(scale:setToX 0.1)
(scale:setToY 0.1)
(transition:setCycleCount Timeline:INDEFINITE)
(transition:setAutoReverse #t)
(transition:play)
(stage:setTitle "JavaFX Scene Graph Demo - Blue Square Animation")
(stage:setScene scene)
;; (stage:setResizable #f)
(stage:show)))
(Application:launch (module-class))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment