Some checks failed
standards workspaces build + test / jouleclaw-rs (pull_request) Successful in 2m13s
standards workspaces build + test / aac-rs (pull_request) Successful in 1m58s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 50s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 34s
standards workspaces build + test / map-rs (pull_request) Successful in 31s
standards workspaces build + test / mesh-rs (pull_request) Successful in 31s
no-vanity-metrics / Scan committed Markdown for vanity metrics (pull_request) Has been cancelled
no-vanity-metrics / WAI public text names no comparison (pull_request) Has been cancelled
no-vanity-metrics / WAI public text names no company or product (pull_request) Has been cancelled
standards workspaces build + test / arl-rs (pull_request) Has been cancelled
standards workspaces build + test / eoc-rs (pull_request) Has been cancelled
standards workspaces build + test / jcp-rs (pull_request) Has been cancelled
standards workspaces build + test / joule-ui-rs (pull_request) Has been cancelled
standards workspaces build + test / jouledesk-rs (pull_request) Has been cancelled
standards workspaces build + test / joulehook-rs (pull_request) Has been cancelled
standards workspaces build + test / proof-rs (pull_request) Has been cancelled
standards workspaces build + test / sandbox-rs (pull_request) Has been cancelled
standards workspaces build + test / sense-rs (pull_request) Has been cancelled
standards workspaces build + test / smart-byte-rs (pull_request) Has been cancelled
standards workspaces build + test / macOS energy backends (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · linux (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · macos (pull_request) Has been cancelled
WAI conformance / quantum core and corpus under wasm32-wasip2 (wasmtime) (pull_request) Has been cancelled
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Has been cancelled
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Has been cancelled
WAI conformance / delivery telemetry · CMCD and CMSD against an independent library (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · linux (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · macos (pull_request) Has been cancelled
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Has been cancelled
WAI energy receipts / energy receipts · linux (pull_request) Has been cancelled
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Has been cancelled
WAI energy receipts / energy receipts · macos (pull_request) Has been cancelled
WAI section references / cited sections exist (pull_request) Has been cancelled
wai-vector vector graphics / linux-aarch64 (pull_request) Has been cancelled
wai-vector vector graphics / linux-x86_64 (pull_request) Has been cancelled
wai-vector vector graphics / macos-arm64 (pull_request) Has been cancelled
wai-vector vector graphics / wasm32-wasip2 (wasmtime) (pull_request) Has been cancelled
wai-vector vector graphics / wasm32 under Node (pull_request) Has been cancelled
wai-vector vector graphics / fuzz, peak allocation, comparison count (pull_request) Has been cancelled
workflow hygiene / every workflow supersedes its own queue (pull_request) Has been cancelled
standards workspaces build + test / openpay (pull_request) Has been cancelled
The reference crate of wai.graphics.vector (no_std + alloc, no dependencies; SHA-256 is wai-ops's, by #[path]): - WOS1 parsed with §2.1's load checks in order, and written; - WVG1 split (steps 1-3, nothing allocated before the exact length), the record pass (step 4), the cross-record checks (step 5(a)-(h)), the sets by digest with at most length + 1 bytes read (step 6), the glyphs (7), the interval check (8) and the per-frame cost (9); - the clock with the frame range by division, track evaluation, and placement; - the JSON authoring form, one member per field, packing back to the same bytes; - the CLI: check, cost, pack, unpack, vectors gen and verify; - a wasm32 module and verify.mjs for Node. The corpus wai/vector-conformance/ (arith, canonical, refusals, geometry, cost) with its README's provenance line and a sha256.json sidecar naming the div255 table; wai-vector.yml with native, wasip2, node and fuzz jobs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
46 lines
1.8 KiB
Rust
46 lines
1.8 KiB
Rust
//! Track evaluation (§3.2), on the driver, in `i64`.
|
|
//!
|
|
//! Linear keys round the exact rational `δ·r/Δ` half up (`R_rat`), so an integer speed
|
|
//! with keys on frame ticks lands every frame on the grid. Easing tables interpolate a
|
|
//! 17-point Q16 table and round the final product half up. Every value lies between
|
|
//! the two keys it interpolates, so an opacity stays in 0..=255 with no clamp, and the
|
|
//! interval check (§3.4(a)) may use the keys' range.
|
|
|
|
use crate::arith::{floor_div, r_half_up, r_rat};
|
|
use crate::wvg1::{Key, Table};
|
|
|
|
/// The value of a track with keys `keys` (at least one, strictly ascending in `t`)
|
|
/// at tick `tau`.
|
|
pub fn eval(keys: &[Key], tables: &[Table], tau: i64) -> i64 {
|
|
let first = &keys[0];
|
|
let last = &keys[keys.len() - 1];
|
|
if tau <= i64::from(first.t) {
|
|
return i64::from(first.value);
|
|
}
|
|
if tau >= i64::from(last.t) {
|
|
return i64::from(last.value);
|
|
}
|
|
let i = keys.partition_point(|k| i64::from(k.t) <= tau) - 1;
|
|
segment(&keys[i], &keys[i + 1], tables, tau)
|
|
}
|
|
|
|
/// The value between two adjacent keys `a` and `b` at `a.t ≤ tau < b.t`.
|
|
pub fn segment(a: &Key, b: &Key, tables: &[Table], tau: i64) -> i64 {
|
|
let dt = i64::from(b.t) - i64::from(a.t);
|
|
let r = tau - i64::from(a.t);
|
|
let v = i64::from(a.value);
|
|
let delta = i64::from(b.value) - v;
|
|
match a.interp {
|
|
0 => v,
|
|
1 => v + r_rat(delta * r, dt),
|
|
j => {
|
|
let e = &tables[j as usize - 2].e;
|
|
let u = floor_div(r << 16, dt);
|
|
let k = (u >> 12) as usize;
|
|
let phi = u & 4095;
|
|
let step = (i64::from(e[k + 1]) - i64::from(e[k])) * phi;
|
|
let ease = i64::from(e[k]) + (step >> 12);
|
|
v + r_half_up(delta * ease, 16)
|
|
}
|
|
}
|
|
}
|