Skip to content

Instantly share code, notes, and snippets.

@rladstaetter
Created January 23, 2013 21:19
Show Gist options
  • Save rladstaetter/4613527 to your computer and use it in GitHub Desktop.
Save rladstaetter/4613527 to your computer and use it in GitHub Desktop.
A glowing line with JavaFX
class GlowingLine extends javafx.application.Application {
val canvasWidth = 1024
val canvasHeight = 768
override def start(primaryStage: Stage): Unit = {
primaryStage.setTitle("Level0")
val root = new BorderPane()
val drawingBoard = new Group()
val background = {
val b = new Rectangle(0, 0, canvasWidth, canvasHeight)
b.setFill(Color.BLACK)
b
}
val refline = new Line(canvasWidth / 10, canvasHeight / 2, canvasWidth * 9 / 10, canvasHeight / 2)
refline.setStroke(Color.WHITESMOKE)
val line = new Line(canvasWidth / 10, canvasHeight / 2, canvasWidth * 9 / 10, canvasHeight / 2)
line.setStroke(Color.WHITE)
line.setStrokeWidth(4)
val bloom = new Bloom(1.0)
val blur = new GaussianBlur()
blur.setInput(bloom)
line.setEffect(blur)
drawingBoard.getChildren().addAll(background, refline, line)
root.setCenter(drawingBoard)
primaryStage.setScene(new Scene(root, canvasWidth, canvasHeight))
primaryStage.show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment