ColourTransformer(uuid?: string, defaultValue?: TColorData)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Standard color light DP protocol converter for bidirectional conversion between HSV values and the device DP hexadecimal protocol

Parameters

ParameterTypeRequiredDescription
uuidstringNoDP identifier, defaults to 'colour_data'
NoDefault HSV value returned when parsing fails

Return Value

Type: ColourTransformer
ColourTransformer instance

Methods

MethodDescription
parserParse a DP hexadecimal string into an HSV value object
formatterFormat an HSV value object as a DP hexadecimal string

Examples

Example

import { ColourTransformer } from '@ray-js/panel-sdk';

const transformer = new ColourTransformer();
// Parse DP string into an HSV object
const hsv = transformer.parser('000003e803e8');
// => { hue: 0, saturation: 1000, value: 1000 }

// Format the HSV object into a DP string
const dpStr = transformer.formatter({ hue: 120, saturation: 800, value: 900 });
// => '007803200384'