Evaluate .curve.json animation curves — supports bezier, linear, constant interpolation.
Project description
curve-eval
Evaluate .curve.json animation curves authored in the Curve Editor VS Code extension. Supports bezier, linear, and constant interpolation for float, int, vec2/3/4, and color types.
Zero dependencies (standard library only). Python 3.9+. Full type hints.
Install
pip install curve-eval
Usage
from curve_eval import evaluate, evaluate_all, evaluate_state
import json
with open('anim.curve.json') as f:
file = json.load(f)
# Absolute time
opacity = evaluate(file, 'fadeIn', 2.5) # → 0.72
color = evaluate(file, 'tint', 1.0) # → {'r': 1.0, 'g': 0.5, 'b': 0.0, 'a': 1.0}
position = evaluate(file, 'position', 0.5) # → (5.0, 2.5, 1.0)
# Normalized time (0–1 maps to the curve's full time range)
mid = evaluate(file, 'fadeIn', 0.5, normalized=True)
# State curves return index + optional label
light = evaluate_state(file, 'trafficLight', 6.0) # → {'index': 1, 'label': 'Yellow'}
# Evaluate every curve at one time
frame = evaluate_all(file, 3.0)
# → {'fadeIn': 0.92, 'scaleX': 1.5, 'trafficLight': 2, 'tint': {'r': 1, ...}}
API
| Function | Returns |
|---|---|
evaluate(file, name, time, *, normalized=False) |
float / int / tuple / dict |
evaluate_all(file, time, *, normalized=False) |
dict[str, value] |
evaluate_state(file, name, time, *, normalized=False) |
{"index": int, "label": str | None} |
get_curve_names(file) |
list[str] |
get_curve_time_range(file, name) |
{"start": float, "end": float} | None |
Interpolation Modes
constant— value holds at the left key until the next key is reachedlinear— straight-line interpolation between keysbezier— cubic bezier with per-key tangent handles (Newton-Raphson solver)
Per-component interpolation is supported on vec/color curves: each component (X/Y/Z or R/G/B/A) can use a different mode on the same keyframe.
Infinity Modes (extrapolation)
Each curve has preInfinity and postInfinity modes that control behavior outside the authored key range:
constant— hold the endpoint valuelinear— extrapolate with the endpoint's tangent slopecycle— loop the authored rangeoscillate— ping-pong the authored range
License
MIT © Glen Rhodes / Tiny Moosh Games Inc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file curve_eval-1.0.0.tar.gz.
File metadata
- Download URL: curve_eval-1.0.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2eb99dc5d815578a01fc9e9e7f92bd0a676b726eb8b94d77533f3244d992d9f
|
|
| MD5 |
15505c9a776e8ddbc3848c131ca33106
|
|
| BLAKE2b-256 |
2341ba839c29384181ec217f6029cadd78046a3ab067f20d9a5bf4aba7253ccc
|
File details
Details for the file curve_eval-1.0.0-py3-none-any.whl.
File metadata
- Download URL: curve_eval-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef3a9fa386855d38158fcc759886879028000075b945105a149b421abbe38d6e
|
|
| MD5 |
053c312d135a111ee3c7ebbf7120f95a
|
|
| BLAKE2b-256 |
5c7544b9b7182fd40685c17b64cba2290f3f9f1c54e77e559c383c1a8fb9dc7e
|