Stats
Actions
Tags
From JavaFX Skills
Animate JavaFX UIs with Timeline, Transition, Canvas, and AnimationTimer-based render loops.
How this skill is triggered — by the user, by Claude, or both
Slash command
/javafx-skills:javafx-animation-canvas-render-loopThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use this skill when the UI needs property animation, custom per-frame drawing, or deterministic
Use this skill when the UI needs property animation, custom per-frame drawing, or deterministic render/update loops built on top of JavaFX primitives.
import javafx.animation.AnimationTimer;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
public class RenderLoopView extends StackPane {
public RenderLoopView() {
var canvas = new Canvas(640, 360);
var gc = canvas.getGraphicsContext2D();
AnimationTimer timer = new AnimationTimer() {
private long lastUpdate;
private double x;
@Override
public void handle(long now) {
if (lastUpdate == 0L) {
lastUpdate = now;
return;
}
double deltaSeconds = (now - lastUpdate) / 1_000_000_000.0;
lastUpdate = now;
x = (x + 120 * deltaSeconds) % canvas.getWidth();
render(gc, canvas.getWidth(), canvas.getHeight(), x);
}
};
timer.start();
getChildren().add(canvas);
}
private void render(GraphicsContext gc, double width, double height, double x) {
gc.setFill(Color.BLACK);
gc.fillRect(0, 0, width, height);
gc.setFill(Color.CORNFLOWERBLUE);
gc.fillOval(x, height / 2 - 20, 40, 40);
}
}
Timeline or Transition when a standard property animation is enough.AnimationTimer only for explicit per-frame control.Canvas is immediate-mode rendering, so redraw responsibility is entirely yours.npx claudepluginhub johannesrabauer/javafx-skills --plugin javafx-skillsGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.