Reputation: 2404
I am building a JavaFX Application that is supposed to run on my RaspberryPi that has a 7" display attached.
For better styling I am trying to animate a javafx.scene.effect.GaussianBlur
-Effect.
I got it "working" although the performance is pretty bad (low FPS during animation) at the moment (on my laptop, not even speaking of the Pi). See code below.
Is there an more performant way of doing this? Or are these Effects just not supposed to be animated?
GaussianBlur blur = new GaussianBlur(0);
backgroundPane.setEffect(blur);
DoubleProperty value = new SimpleDoubleProperty(0);
value.addListener((observable, oldV, newV)->
{
blur.setRadius(newV.doubleValue());
});
Timeline timeline = new Timeline();
final KeyValue kv = new KeyValue(value, 30);
final KeyFrame kf = new KeyFrame(Duration.millis(200), kv);
timeline.getKeyFrames().add(kf);
timeline.play();
FYI: The bakcgroundPlane
is at this stage just a Pane with a Background image added via CSS:
.background
{
-fx-background-image: url("images/bg.png");
-fx-background-repeat: stretch;
-fx-background-size: 800 480;
-fx-background-position: center center;
}
EDIT: The problem doesn't seem to be related to the CSS. It still occures, when I set the image in the FXML...
Upvotes: 3
Views: 990
Reputation: 378
Have you tried to enable caching and set the cache hint to speedy?
Those usually have a massive impact on performance. On one of my little jfx games it was the difference between "playable" and single digit fps values.
Upvotes: 2