β‘ 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 the Demo (YouTube) | Watch the JMH Benchmark
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
- Features
- Performance Benchmarks
- API Quick Reference
- Technical Examples & Hero Demos
- 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.
- β‘ 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.
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. |
| 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.age. Maximum speed. Zero bloat. ππ
