Skip to content

Commit

Permalink
fix: color encoding and brightness (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske authored Sep 4, 2024
1 parent 0d7baf5 commit 86f35d9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion convention.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ needs this, then it should provide an escape mechanism on the application level.

- Color payload validity varies depending on the property format definition of either "rgb", "hsv", or "xyz"
- All payload types contain comma-separated data of differing restricted ranges. The first being the type, followed by numbers. The numbers must conform to the [float](#float) format
- The encoded string may only contain the [float](#float) numbers and the comma character ",", no other characters are permitted, including spaces (" ")
- The encoded string may only contain the type, the [float](#float) numbers and the comma character ",", no other characters are permitted, including spaces (" ")
- Payloads for type "rgb" contain 3 comma-separated values of [floats](#float) (`r`, `g`, `b`) with a valid range between 0 and 255 (inclusive). e.g. `"rgb,100,100,100"`
- Payloads for type "hsv" contain 3 comma-separated values of [floats](#float). The first number (`h`) has a range of 0 to 360 (inclusive), and the second and third numbers (`s` and `v`) have a range of 0 to 100 (inclusive). e.g. `"hsv,300,50,75"`
- Payloads for type "xyz" contain 2 comma separated values of [floats](#float) (`x`, `y`) with a valid range between 0 and 1 (inclusive). The "z" value can be calculated via `z=1-x-y` and is therefore not transmitted. (see [CIE_1931_color_space](https://en.wikipedia.org/wiki/CIE_1931_color_space)). e.g. `"xyz,0.25,0.34"`
- *Note*: The `rgb` and `hsv` formats encode both color and brightness, whereas `xyz` only encodes the color, so;
- when brightness encoding is required: do not use `xyz`, or optionally add another property for the brightness (such that setting `hsv` and `rgb` values changes both the color property and the brightness one if required)
- if color only is encoded: ignore the `v` value in `hsv`, and use the relative colors of `rgb`
eg. `color_only_r = 255 * r / max(r, g, b)`, etc.
- An [empty string](#empty-string-values) ("") is not a valid payload

### DateTime
Expand Down

0 comments on commit 86f35d9

Please sign in to comment.