UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

36 lines 1.16 kB
import { Node } from '../../programmatic/node.js'; import { NumberSchema } from '../../schemas/index.js'; export default class NodeDefinition extends Node { static title = 'Lerp'; static type = 'studio.tokens.math.lerp'; static description = "Lerp (linear interpolation) calculates a value between two numbers, A and B, based on a fraction t. For t = 0 returns A, for t = 1 returns B. It's widely used in graphics and animations for smooth transitions."; constructor(props) { super(props); this.addInput('a', { type: { ...NumberSchema, default: 0 } }); this.addInput('b', { type: { ...NumberSchema, default: 0 } }); this.addInput('t', { type: { ...NumberSchema, default: 0 } }); this.addOutput('value', { type: NumberSchema }); } execute() { const { a, b, t } = this.getAllInputs(); this.outputs.value.set(a + t * (b - a)); } } //# sourceMappingURL=lerp.js.map