UNPKG

@tokens-studio/graph-engine

Version:

An execution engine to handle Token Studios generators and resolvers

56 lines 1.74 kB
import { ColorSchema, NumberSchema, StringSchema } from '../../schemas/index.js'; import { Node } from '../../programmatic/node.js'; export { ColorModifierTypes } from '@tokens-studio/types'; import { ColorSpaces } from './lib/spaces.js'; export default class NodeDefinition extends Node { static title = 'Create Color'; static type = 'studio.tokens.color.create'; static description = 'Creates a color in a given color space with the specified channel values (using the ports a, b, c, etc) and returns it as a color object'; constructor(props) { super(props); this.addInput('space', { type: { ...StringSchema, enum: ColorSpaces, default: 'srgb' } }); this.addInput('a', { type: { ...NumberSchema, default: '0' } }); this.addInput('b', { type: { ...NumberSchema, default: '0' } }); this.addInput('c', { type: { ...NumberSchema, default: '0' } }); //No default on alpha as this might result in Hex8 colors which are not always desired this.addInput('alpha', { type: { ...NumberSchema } }); this.addOutput('value', { type: ColorSchema }); } execute() { const { a, b, c, alpha, space } = this.getAllInputs(); const color = { space, channels: [a, b, c], alpha: alpha }; this.outputs.value.set(color); } } //# sourceMappingURL=create.js.map