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.3.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.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: curve_eval-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 1f39ae7062f34dd1181c761152cd26bb88eba49bc5e306582191dddd5cd9a7d9
MD5 40e2cfd48ecfee6c45dd2bc5ffc5830d
BLAKE2b-256 e11eed89f818b91e2bee136b44280e0abb8c16dddf3218669fef75ee145edcbe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: curve_eval-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 496e3f36e74dd46a59caa8571ce249739314b97099d17b52e6ae8a667d70ba0c
MD5 a8671c1a53b91277dbbd1cecb30a2638
BLAKE2b-256 9090b6809412b6d023d01353075ffdb25bb7852a6fa2d6055f2c082ab2d52167

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