Spaces:
Running
Running
File size: 1,516 Bytes
b9499ab | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import type { Step } from "./types";
// Forward pass: copies of the numbers travel to the node, the operation is applied, the result settles above it
export const TRAVEL_MS = 900;
export const APPLY_MS = 750;
const RESULT_HOLD_MS = 350;
export const SETTLE_MS = 500;
export const RESULT_AT = TRAVEL_MS + APPLY_MS;
export const SETTLE_AT = RESULT_AT + RESULT_HOLD_MS;
export const FORWARD_MS = SETTLE_AT + SETTLE_MS;
// The backward pass starts with the seed moving from f to the output node
export const SEED_HOLD_MS = 300;
export const SEED_TRAVEL_MS = 700;
export const SEED_MS = SEED_HOLD_MS + SEED_TRAVEL_MS + SETTLE_MS;
// A derivative goes halfway along each edge, is multiplied by the edge's partial, carries on
// to the far end, and is added to what's there. These times count from when it sets off.
export const OUT_MS = 650;
const MULTIPLY_MS = 750;
const PRODUCT_MS = 350;
export const IN_MS = 650;
const LAND_MS = 500;
const SUM_MS = 200;
export const PRODUCT_AT = OUT_MS + MULTIPLY_MS;
export const IN_AT = PRODUCT_AT + PRODUCT_MS;
export const LAND_AT = IN_AT + IN_MS;
export const SUM_AT = LAND_AT + LAND_MS;
export const FADE_AT = SUM_AT + SUM_MS;
export const DERIVATIVE_MS = FADE_AT + SETTLE_MS;
export function flowDuration(step: Step): number {
if (step.phase === "forward") {
// Forward mode's tangents set off as the value settles
return step.derivative === undefined ? FORWARD_MS : SETTLE_AT + DERIVATIVE_MS;
}
return step.partials.length === 0 ? SEED_MS : DERIVATIVE_MS;
}
|