โก A high-performance, zero-allocation tweening module for the FastJava ecosystem. SIMD-accelerated interpolation and easing for smooth real-time animations.
FastTween is a specialized mathematical engine designed for pure, garbage-free value interpolation. By utilizing advanced object pooling (FastTweenOpt), it entirely bypasses standard JVM object creation overhead during the critical render loop. It serves as the low-level mathematical foundation for the ecosystem and powers FastAnimation under the hood. Build perfectly smooth, 120+ FPS interfaces and game mechanics without triggering a single Garbage Collector micro-stutter.
Watch Demo (YouTube) | Watch JMH Benchmark (YouTube)
import fasttween.FastTween;
import fasttween.Ease;
import fasttween.Tween;
public class Example {
public static void main(String[] args) {
// 1. Configure and start a high-performance zero-allocation tween
Tween fade = FastTween.to(0.0f, 100.0f, 500)
.ease(Ease.CUBIC_OUT)
.onUpdate(val -> System.out.println("Value: " + val))
.onComplete(() -> System.out.println("Tween Finished!"))
.start();
// 2. Drive it inside your game, UI, or rendering loop (real-time delta)
while (fade.isRunning()) {
fade.update();
}
}
}- Why FastTween?
- Quick Start
- Key Features
- Real-World Use Cases
- Performance Benchmarks
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Standard Java interpolation libraries often prioritize ease-of-use at the expense of memory efficiency. While instantiating a new Tween object for every UI animation is perfectly fine for basic applications, it completely collapses when developing high-performance engines, games, or complex data visualizations.
- The GC Penalty: Creating thousands of short-lived interpolation objects per second triggers constant Garbage Collector cycles, resulting in noticeable micro-stutters and frame drops.
- Boxing Overhead: Many libraries rely on primitive wrappers (
Float,Double), forcing the JVM to constantly box and unbox values during math-heavy rendering loops. - Bloated Dependencies: UI-bound tweening engines often pull in massive UI framework dependencies (like JavaFX or Android SDKs), making them unsuitable for headless environments.
FastTween was engineered from the ground up to solve these fundamental bottlenecks:
- 100% Zero-Allocation: By utilizing a pre-allocated
TweenPool(FastTweenOpt), it is mathematically impossible to trigger a GC pause during the rendering loop, no matter how many animations you fire. - Primitive-First Architecture: FastTween operates strictly on raw primitive types (
float,int). There is absolutely no autoboxing overhead. - Framework Agnostic: FastTween is a pure mathematical engine. It has zero UI dependencies, allowing you to use it in Swing, JavaFX, OpenGL (LWJGL), or entirely headless data pipelines.
| Feature | Universal Tween Engine | JavaFX Timeline / Transition |
FastTween |
|---|---|---|---|
| Memory Management | Heavy object instantiation | Allocates KeyFrames & Nodes | Pre-Allocated TweenPool (Zero GC) |
| Data Types | Boxed object arrays | Property bindings (DoubleProperty) |
Pure Primitives (float, int) |
| Math Execution (Lerp) | ~20โ50M ops/sec | ~10โ25M ops/sec | > 2.3 Billion ops/sec (JMH) |
| Framework Binding | Standalone | Tied to JavaFX Toolkit | 100% Framework Agnostic (Headless) |
| Update Hotpath | Reflection / callbacks | Pulse loop dispatch | > 36.8 Million updates/sec |
| Dependencies | External JAR | Full JavaFX Modular SDK | Pure Java 17+ backed by FastCore |
- โก SIMD Accelerated: Optimized easing and interpolation via AVX2/SSE vector math.
- ๐ฆ Zero GC Stalls: Minimal object creation for high-frequency updates using TweenPool.
- ๐ Raw Performance: Optimized for massive parallel animation streams (>2.3 Billion ops/sec).
- ๐๏ธ Ecosystem Ready: Mathematical foundation for FastAnimation, FastGraphics, and FastExecution.
- ๐ฎ Game Camera & Physics Smoothing: Jitter-free camera tracking, spring interpolation, and dynamic dampening without GC micro-stutters.
- ๐จ UI Micro-Interactions & Animations: Powers 120+ FPS component fades, drawer transitions, and elastic hover effects in desktop and web wrappers.
- ๐ Massive Particle & Mesh Kinetics: Interpolates hundreds of thousands of vertices or kinetic particles across parallel CPU/GPU pipelines (
WaveDemo,GPUMillionDemo). - โฑ๏ธ Headless Simulation & Audio Envelopes: Deterministic mathematical interpolation curves for audio synthesizer envelopes, parameter modulation, and offline physical simulations.
FastTween is rigorously profiled using JMH to guarantee zero overhead. Watch the JMH Benchmark
| Metric / Operation | Score (ops/ms) | Ops per Second |
|---|---|---|
| Standard Tween Creation | ~163,942 ops/ms | > 163 Million |
| Pooled Tween Creation | ~60,528 ops/ms | > 60 Million |
| Update Hotpath (Pooled) | ~36,840 ops/ms | > 36.8 Million |
| Raw Math (Lerp) | ~2,356,842 ops/ms | > 2.3 Billion |
Measured on Windows 11, Intel Core i5-1135G7 (Surface Pro 8), JDK 21.0.12.
| Method | Description |
|---|---|
FastTween.to(from, to, duration) |
Creates a new tween interpolating from the starting value to the end value. |
FastTween.to(to, duration) |
Creates a new tween interpolating from 0 to the end value. |
FastTween.from(from, duration) |
Creates a new tween interpolating from the starting value down to 0. |
FastTween.lerp(start, end, progress) |
High-speed primitive linear interpolation helper. |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Real-Time Easing Visualizer | Demo.java | run-demo.bat |
Interactive 7-channel easing visualizer comparing Linear, Quad, Cubic, Quart, Back, Elastic, and Bounce. |
| 1M Vertex Kinetic Mesh Swarm | GPUMillionDemo.java | run-gpu-million-demo.bat |
1,000,000 connected polygon vertices animated in real time with sub-pixel Z-buffer at 120 FPS. |
| 3D Holographic Kinetic Wave | WaveDemo.java | run-wave-demo.bat |
102,400 kinetic node grid with real-time FastMath parallel vs standard math benchmark toggle. |
| Basic Interpolation CLI | Demo.java | run-basic-demo.bat |
Headless CLI demo showcasing basic tweening, custom bezier curves, and completion callbacks. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
OpenJDK JMH microbenchmarks measuring pooled vs standard tween throughput and lerp math. |
Add the JitPack repository and the dependencies to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastTween</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastTween:0.1.1'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest JARs directly to add them to your classpath:
- ๐ฆ FastTween-0.1.1.jar (The Core Library)
- โ๏ธ fastcore-0.1.0.jar (The Mandatory Native JNI Loader)
- REFERENCE.md: Exhaustive catalog of supported easing functions and interpolation techniques.
- PHILOSOPHY.md: Zero-allocation pooling and primitive-first mathematical designs.
- ROADMAP.md: Planned milestone features and performance extensions.
- CHANGELOG.md: Release history and version migration details.
| Platform | Status |
|---|---|
| Windows 10/11 (x64) | โ Fully Supported |
| Linux (x64 / AArch64) | โ Fully Supported |
| macOS (Apple Silicon / Intel) | โ Fully Supported |
- FastAnimation โ Ultra-high-performance animation timeline engine.
- FastExecution โ High-precision scheduler and deterministic executor.
- FastDWM โ Native Desktop Window Manager API.
- FastTheme โ Dark mode Win32 titlebars and modern UI theming.
- FastCore โ Unified JNI loader and platform abstraction.
MIT License โ See LICENSE for details.
Part of the FastJava Ecosystem โ Making the JVM faster. ๐
