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.
Metadata
Release files for curve-eval 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| curve_eval-1.0.0.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| curve_eval-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / curve_eval-1.0.0.tar.gz
| Download URL | curve_eval-1.0.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2eb99dc5d815578a01fc9e9e7f92bd0a676b726eb8b94d77533f3244d992d9f
|
|
BLAKE2b-256 checksum How to use checksums |
2341ba839c29384181ec217f6029cadd78046a3ab067f20d9a5bf4aba7253ccc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / curve_eval-1.0.0-py3-none-any.whl
| Download URL | curve_eval-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef3a9fa386855d38158fcc759886879028000075b945105a149b421abbe38d6e
|
|
BLAKE2b-256 checksum How to use checksums |
5c7544b9b7182fd40685c17b64cba2290f3f9f1c54e77e559c383c1a8fb9dc7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|