Creating Visual Effects in JavaFX
2 Using the Bloom Effect
The bloom effect makes brighter portions an image appear to glow, based on a configurable threshold. The threshold varies from 0.0 to 1.0. By default, the threshold is set to 0.3.
Figure 2-1 shows the bloom effect at the default threshold and at a threshold of 1.0.
Example 2-1 shows a code snippet from the sample application that is using the bloom effect.
Example 2-1 Bloom Example
static Node bloom() { Group g = new Group(); Rectangle r = new Rectangle(); r.setX(10); r.setY(10); r.setWidth(160); r.setHeight(80); r.setFill(Color.DARKBLUE); Text t = new Text(); t.setText("Bloom!"); t.setFill(Color.YELLOW); t.setFont(Font.font("null", FontWeight.BOLD, 36)); t.setX(25); t.setY(65); g.setCache(true); //g.setEffect(new Bloom()); Bloom bloom = new Bloom(); bloom.setThreshold(1.0); g.setEffect(bloom); g.getChildren().add(r); g.getChildren().add(t); g.setTranslateX(350); return g; }