RGB
Root / Documentation / [.]
Created:
Create, split, or modify color codes.
* Create Color Code
Create a color code value given its channel values.
```sbsyntax
RGB { alpha%, } red%, green%, blue% OUT color%
```
|* Input | Description |
| `alpha%` | The alpha (transparency) channel (0-255). Optional, defaults to 255 |
| `red%` |#rs=3 The color channels (0-255). |
| `green%` |
| `blue%` |
|* Output | Description |
| `color%` | Integer value encoding a 32-bit ARGB color. |
* Split Color Code
Split a color code into its channels.
```sbsyntax
RGB color% OUT { alpha%, } red%, green%, blue%
```
|* Input | Description |
| `color%` | Integer value encoding a 32-bit ARGB color. |
|* Output | Description |
| `alpha%` | The alpha (transparency) channel, 0-255 (optional.) |
| `red%` |#rs=3 The color channels (0-255). |
| `green%` |
| `blue%` |
* Replace Channels
Replace channels in color
```sbsyntax
RGB oldColor%, { alpha% }, { red% }, { green% }, { blue% } OUT newColor%
```
|* Input | Description |
| `oldColor%` | The color code value to modify. |
| `alpha%` |#rs=4 Optional, will replace channels in `oldColor%` if specified, (0-255). |
| `red%` |
| `green%` |
| `blue%` |
|* Output | Description |
| `newColor%` | `oldColor%`, with channels replaced by `alpha%`, `red%`, `green%`, and `blue%` if specified. |
* Examples
```sb4
BACKCOLOR RGB(255,128,0) 'change background color to orange
```
```sb4
RGB #C_MAGENTA OUT R,G,B
?R,G,B '255, 0, 255
```
```sb4
C = RGB(0,224,255)
C2 = RGB(C,,128,,) 'replace red channel with 128
RGB C2 OUT R,G,B
?R,G,B '128,224,255
```
No posts yet (will you be the first?)