Skip to main content

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 reached
  • linear — straight-line interpolation between keys
  • bezier — 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 value
  • linear — extrapolate with the endpoint's tangent slope
  • cycle — loop the authored range
  • oscillate — ping-pong the authored range

License

MIT © Glen Rhodes / Tiny Moosh Games Inc.

Source: https://github.com/glenwrhodes/CurveEditor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curve_eval-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

curve_eval-0.1.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file curve_eval-0.1.2.tar.gz.

File metadata

  • Download URL: curve_eval-0.1.2.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

Hashes for curve_eval-0.1.2.tar.gz
Algorithm Hash digest
SHA256 02a1869a93d22d4d4e39069ac2cac86f4a32de4118f3331a20ad7a5d0139c0e0
MD5 fa5d4e4d331147dc75bc59a988c9683f
BLAKE2b-256 882b6d1d6d67280c5aff91b7f25378a4b48a1ead2c789e195db61e845abf46d3

See more details on using hashes here.

File details

Details for the file curve_eval-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: curve_eval-0.1.2-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

Hashes for curve_eval-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1e03d5299bb0a6e350d3ba0ef2d332507a2e282c1ff214cb4e281efe6e2e477
MD5 13bfa4ad3b2f297e69fd240df53f6020
BLAKE2b-256 d07eb1189bd4ee759d28448c1efe68db0b22fd4b78f22530b145a82a9110d6e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page