Created
September 8, 2018 22:23
-
-
Save hudsonb/bee3f7f42c50ce15073734d296ec8140 to your computer and use it in GitHub Desktop.
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.AnimationTimer | |
import javafx.application.Application | |
import javafx.scene.Group | |
import javafx.scene.Scene | |
import javafx.scene.SnapshotParameters | |
import javafx.scene.image.ImageView | |
import javafx.scene.image.WritableImage | |
import javafx.scene.paint.Color | |
import javafx.scene.shape.ClosePath | |
import javafx.scene.shape.LineTo | |
import javafx.scene.shape.MoveTo | |
import javafx.scene.shape.Path | |
import javafx.stage.Stage | |
class Test : Application() { | |
override fun start(stage: Stage?) { | |
val width = 960.0 | |
val height = 600.0 | |
val group = Group() | |
val wi = WritableImage(width.toInt(), height.toInt()) | |
group.children += ImageView(wi) | |
val path = Path() | |
group.children += path | |
val params = SnapshotParameters() | |
params.fill = Color.TRANSPARENT | |
val t = object : AnimationTimer() { | |
override fun handle(now: Long) { | |
group.snapshot(params, wi) | |
path.elements.clear() | |
path.stroke = Color.BLACK | |
path.elements += MoveTo(0.0, 0.0) | |
path.elements += LineTo(0.0, height) | |
path.elements += LineTo(width, height) | |
path.elements += LineTo(width, 0.0) | |
path.elements += LineTo(0.0, 0.0) | |
path.elements += ClosePath() | |
} | |
} | |
t.start() | |
val scene = Scene(group) | |
stage?.width = width | |
stage?.height = height | |
stage?.scene = scene | |
stage?.show() | |
} | |
} | |
fun main(args: Array<String>) { | |
Application.launch(Test::class.java, *args) | |
} |
Author
hudsonb
commented
Sep 8, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment