hsv2rgb(h: number, s: number, v: number, a?: number)

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

Description

Convert HSV to the RGB color model

Parameters

ParameterTypeRequiredDescription
hnumberYesHue (0-360)
snumberYesSaturation (0-100)
vnumberYesValue (0-100)
anumberNoOptional alpha (0-1)

Return Value

Type: number[]
RGB array [r, g, b], each channel in 0-255

Examples

Basic usage

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

const { hsv2rgb } = utils;

hsv2rgb(0, 100, 100);   // [255, 0, 0]  Red
hsv2rgb(120, 100, 100);  // [0, 255, 0]  Green
hsv2rgb(240, 100, 100);  // [0, 0, 255]  Blue

rgb2hsv(r: number, g: number, b: number)

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

Description

Convert RGB to the HSV color model

Parameters

ParameterTypeRequiredDescription
rnumberYesRed channel (0-255)
gnumberYesGreen channel (0-255)
bnumberYesBlue channel (0-255)

Return Value

Type: number[]
HSV array [h, s, v], where h is hue (0-360), s is saturation (0-100), v is value (0-100)

Examples

Basic usage

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

const { rgb2hsv } = utils;

rgb2hsv(255, 0, 0);   // [0, 100, 100]  Red
rgb2hsv(0, 255, 0);   // [120, 100, 100] Green
rgb2hsv(128, 128, 128); // [0, 0, 50]    Gray

hex2hsv(hex: string)

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

Description

Convert a hex color to the HSV model

Parameters

ParameterTypeRequiredDescription
hexstringYesHex color string, e.g., '#FF0000' or 'FF0000'

Return Value

Type: number[]
HSV array [h, s, v], where h is hue (0-360), s is saturation (0-100), v is value (0-100)

Examples

Basic usage

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

const { hex2hsv } = utils;

hex2hsv('#FF0000'); // [0, 100, 100]
hex2hsv('#00FF00'); // [120, 100, 100]

hex2rgbString(hex: string, a?: number)

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

Description

Convert a hex color to a CSS RGB/RGBA string

Parameters

ParameterTypeRequiredDescription
hexstringYesHex color string, e.g., '#FF0000' or 'FF0000'
anumberNoOptional alpha (0-1)

Return Value

Type: string
CSS color string, e.g., 'rgb(255, 0, 0)' or 'rgba(255, 0, 0, 0.5)'

Examples

Basic usage

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

const { hex2rgbString } = utils;

hex2rgbString('#FF0000');       // 'rgb(255, 0, 0)'
hex2rgbString('#FF0000', 0.5); // 'rgba(255, 0, 0, 0.5)'

hsv2rgbString(h: number, s: number, v: number, a?: number)

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

Description

Convert HSV to a CSS RGB/RGBA string

Parameters

ParameterTypeRequiredDescription
hnumberYesHue (0-360)
snumberYesSaturation (0-100)
vnumberYesValue (0-100)
anumberNoOptional alpha (0-1)

Return Value

Type: string
CSS color string, e.g., 'rgb(255, 0, 0)' or 'rgba(255, 0, 0, 0.5)'

Examples

Basic usage

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

const { hsv2rgbString } = utils;

hsv2rgbString(0, 100, 100);      // 'rgb(255, 0, 0)'
hsv2rgbString(120, 100, 100, 0.8); // 'rgba(0, 255, 0, 0.8)'

brightKelvin2rgb(bright?: any, temperature?: any, kelvinRange?: KelvinRange)

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

Description

Convert brightness and color temperature values to an RGB color string

Parameters

ParameterTypeRequiredDescription
brightanyNoBrightness value, range 1–1000
temperatureanyNoColor temperature value, range 0–1000
NoOptional color temperature range config; kelvinMin defaults to 2200, kelvinMax defaults to 6500

Return Value

Type: string
RGB or RGBA color string, e.g., 'rgb(255, 200, 150)'

Examples

Basic usage

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

const { brightKelvin2rgb } = utils;

const color = brightKelvin2rgb(1000, 1000); // max brightness, max color temperature
const warm = brightKelvin2rgb(500, 0);      // medium brightness, minimum color temperature (warm light)
const custom = brightKelvin2rgb(800, 500, { kelvinMin: 2700, kelvinMax: 6500 });

rgb2RgbString(originRgb: number[], a?: number)

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

Description

Convert an RGB numeric array to a CSS color string

Parameters

ParameterTypeRequiredDescription
originRgbnumber[]YesRGB or RGBA numeric array, e.g., [255, 0, 0] or [255, 0, 0, 0.5]
anumberNoOptional alpha transparency value (0–1), effective when the array has 3 elements

Return Value

Type: string
CSS color string, e.g., 'rgb(255, 0, 0)' or 'rgba(255, 0, 0, 0.5)'

Examples

Basic usage

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

const { rgb2RgbString } = utils;

rgb2RgbString([255, 0, 0]);       // 'rgb(255, 0, 0)'
rgb2RgbString([255, 0, 0], 0.5);  // 'rgba(255, 0, 0, 0.5)'
rgb2RgbString([255, 0, 0, 0.8]);  // 'rgba(255, 0, 0, 0.8)'

kelvin2rgb(kelvin: number)

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

Description

Convert a Kelvin color temperature to an RGB array

Parameters

ParameterTypeRequiredDescription
kelvinnumberYesKelvin color temperature (recommended range 1000K - 40000K)

Return Value

Type: number[]
RGB array [r, g, b], each channel in 0-255

Examples

Basic usage

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

const { kelvin2rgb } = utils;

const rgb = kelvin2rgb(6500); // Daylight color temperature, close to [255, 249.574170569891, 254.30625501058964]
const warm = kelvin2rgb(2700); // Warm white color temperature

rgb2kelvin(rgb: number[])

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

Description

Convert RGB to a Kelvin color temperature

Parameters

ParameterTypeRequiredDescription
rgbnumber[]YesRGB array [r, g, b]

Return Value

Type: number
Corresponding Kelvin color temperature (integer)

Examples

Basic usage

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

const { rgb2kelvin } = utils;

const kelvin = rgb2kelvin([255, 255, 255]); // approximately 6524

rgb2hsb(r: number, g: number, b: number)

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

Description

Convert RGB to the HSB color model

Parameters

ParameterTypeRequiredDescription
rnumberYesRed channel (0-255)
gnumberYesGreen channel (0-255)
bnumberYesBlue channel (0-255)

Return Value

Type: number[]
HSB array [h, s, b], equivalent to the HSV model

Examples

Basic usage

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

const { rgb2hsb } = utils;

rgb2hsb(255, 0, 0); // [0, 100, 100]

rgb2hex(r: number, g: number, b: number)

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

Description

Convert RGB to a hex color string

Parameters

ParameterTypeRequiredDescription
rnumberYesRed channel (0-255)
gnumberYesGreen channel (0-255)
bnumberYesBlue channel (0-255)

Return Value

Type: string
Hex color string, e.g., '#FF0000'

Examples

Basic usage

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

const { rgb2hex } = utils;

rgb2hex(255, 0, 0); // '#FF0000'
rgb2hex(0, 255, 0); // '#00FF00'