---
name: "ColourDataRawTransformer"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "ColourDataRawTransformer"
summary: "ColourDataRawTransformer is used to parse the lighting `colour_data_raw` DP and provides parsing and formatting for the raw color data format."
questions:
  - "What is ColourDataRawTransformer used for?"
  - "How does ColourDataRawTransformer parse the raw color data format?"
  - "What are the input and output of ColourDataRawTransformer?"
  - "What are the transformation rules of ColourDataRawTransformer?"
---

## ColourDataRawTransformer

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 Color light Raw-type DP for lighting products (e.g., colour_data_raw). It differs in that:
> - The protocol format is hue (4 digits) + saturation (2 digits) + value (2 digits), totaling 8 hexadecimal characters
> - saturation and value are multiplied by 10 when parsing and divided by 10 when formatting, with a range of 0–1000

### Description

Color light Raw-type DP protocol converter for bidirectional conversion between HSV values and the Raw DP hexadecimal protocol

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `uuid` | `string` | No | DP identifier, defaults to 'colour_data_raw' |
| `defaultValue` | `TColorData` | No | Default HSV value returned when parsing fails |

### Return Value

Type: `ColourDataRawTransformer`

ColourDataRawTransformer instance

#### Methods

| Method | Description |
| --- | --- |
| `parser` | Parse the Raw DP hexadecimal string into an HSV value object |
| `formatter` | Format the HSV value object into a Raw DP hexadecimal string |

### Referenced Types

##### `type` TColorData

| Property | Type | Description |
| --- | --- | --- |
| `hue` | `number` | Hue |
| `saturation` | `number` | Saturation |
| `value` | `number` | Brightness |


### Examples

#### Example

```ts
import { ColourDataRawTransformer } from '@ray-js/panel-sdk';

const transformer = new ColourDataRawTransformer();
// Parse Raw DP string
const hsv = transformer.parser('00780a0a');
// => { hue: 120, saturation: 100, value: 100 }

// Format to Raw DP string
const dpStr = transformer.formatter({ hue: 120, saturation: 100, value: 100 });
// => '0078000a000a' (hue 4 digits + saturation/10 2 digits + value/10 2 digits)
```
