@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
38 lines • 1.32 kB
JavaScript
import { Black, toColor, toColorObject } from './lib/utils.js';
import { ColorSchema, NumberSchema } from '../../schemas/index.js';
import { Node } from '../../programmatic/node.js';
export { ColorModifierTypes } from '@tokens-studio/types';
export default class NodeDefinition extends Node {
static title = 'Lighten Color';
static type = 'studio.tokens.color.lighten';
static description = 'Lightens a color by a specified value';
constructor(props) {
super(props);
this.addInput('color', {
type: {
...ColorSchema,
default: Black
}
});
this.addInput('value', {
type: {
...NumberSchema,
default: 0.5,
description: 'Value to apply to the modifier'
}
});
this.addOutput('value', {
type: ColorSchema
});
}
execute() {
const { value, color } = this.getAllInputs();
const sourceColor = toColor(color);
const lightness = sourceColor.oklch.l;
const newLightness = lightness + (1 - lightness) * value;
sourceColor.oklch.l = newLightness;
const final = toColorObject(sourceColor);
this.outputs.value.set(final);
}
}
//# sourceMappingURL=lighten.js.map