UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

63 lines 1.78 kB
import { CurveSchema, NumberSchema } from '../../schemas/index.js'; import { Node } from '../../programmatic/node.js'; export default class BezierCurveNode extends Node { static title = 'Bezier Curve'; static type = 'studio.tokens.curve.bezier'; static description = 'Creates a bezier curve from two control points'; constructor(props) { super(props); this.addInput('x1', { type: { ...NumberSchema, default: 0.5, minimum: 0, maximum: 1 } }); this.addInput('y1', { type: { ...NumberSchema, default: 0, minimum: 0, maximum: 1 } }); this.addInput('x2', { type: { ...NumberSchema, default: 0.5, minimum: 0, maximum: 1 } }); this.addInput('y2', { type: { ...NumberSchema, default: 1, minimum: 0, maximum: 1 } }); this.addOutput('curve', { type: CurveSchema }); } execute() { const { x1, y1, x2, y2 } = this.getAllInputs(); const curve = { curves: [ { type: 'bezier', points: [ [0, 0], // Start point [x1, y1], // First control point [x2, y2], // Second control point [1, 1] // End point ] } ] }; this.outputs.curve.set(curve); } } //# sourceMappingURL=bezier.js.map