Skip to content

Commit f5fdcd9

Browse files
author
IliasHDZ
authored
Adding documentation about level colors (#55)
* Adding documentation about level colors * Fix typos * Added description of LBG and some fixes
1 parent a343514 commit f5fdcd9

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
- [Level](/resources/client/level.md)
3131
- [Object IDs](/resources/client/level-components/objectids.md)
32+
- [Level Colors](/resources/client/level-components/level-colors.md)
3233
- [Inner Level String](/resources/client/level-components/inner-level-string.md)
3334
- [Level Object](/resources/client/level-components/level-object.md)
3435
- [Color String](/resources/client/level-components/color-string.md)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Level Colors
2+
This document goes in depth on how colors, copy colors and player color work as base colors or in color/pulse triggers.
3+
4+
## Color classes
5+
There are 3 color classes (not to be confused with the GD's classes). Every aspect in GD levels that use colors only take one of the classes. All of the properties that do not belong to the color class being used is ignored.
6+
7+
### BaseColor
8+
This class contains a static color along with opacity and blending.
9+
10+
These are the properties that are important for a BaseColor:
11+
12+
| Name | Type | Description |
13+
|:---------|:------------|:----------------------|
14+
| Red | **integer** | The red component of the BaseColor. Goes from `0` to `255` |
15+
| Green | **integer** | The green component of the BaseColor. Goes from `0` to `255` |
16+
| Blue | **integer** | The blue component of the BaseColor. Goes from `0` to `255` |
17+
| Opacity | **float** | The alpha component of the BaseColor. Goes from `0` to `1` |
18+
| Blending | **bool** | The blending property of the BaseColor |
19+
20+
**Note**: Blending causes the color to add its color properties by basically using the OpenGL blend mode `glBlendFunc(GL_SRC_ALPHA, GL_ONE)`
21+
22+
### PlayerColor
23+
This class contains a static color refering to one of the player's icon color along with opacity and blending.
24+
25+
These are the properties that are important for a PlayerColor:
26+
27+
| Name | Type | Description |
28+
|:-------------|:------------|:----------------------|
29+
| Player Color | **integer** | This determines which of the player's color is getting used. The actual values are not documented here yet. |
30+
| Opacity | **float** | The alpha component of the PlayerColor. Goes from `0` to `1` |
31+
| Blending | **bool** | The blending property of the PlayerColor |
32+
33+
### CopyColor
34+
This class contains a dynamic color copied from another color channel. This color changes according to the current color of the channel that is being copied.
35+
36+
| Name | Type | Description |
37+
|:----------------|:------------|:----------------------|
38+
| Copy Channel ID | **integer** | The color channel ID that the CopyColor is copying the color from |
39+
| Copy Opacity | **bool** | This determines whenever CopyColor should also copy the opacity belonging to the color channel in `Copy Color ID` |
40+
| Opacity | **float** | The alpha component of the Copy Color. If `Copy Opacity` is true. This property is ignored. |
41+
| Blending | **bool** | The blending property of the CopyColor since it cannot be copied |
42+
| Copy HSV | **[HSV](resources/client/level-components/level-object.md?id=object-string)** | The HSV property that changes the color's tint depending on the value |
43+
44+
### Determining which class is used
45+
Here is a simple JavaScript function that determines what color class the color object has:
46+
47+
```javascript
48+
function getColorClass(color) {
49+
if (color.copy_channel_id != 0)
50+
return COPY_COLOR;
51+
52+
if (color.player_color != PLAYER_COLOR_NONE)
53+
return PLAYER_COLOR;
54+
55+
return BASE_COLOR;
56+
}
57+
```
58+
59+
## Color Channel ID's
60+
Here are all of the different color id's:
61+
62+
| Interval | Name | Description |
63+
|:----------|:------------------|:----------------------|
64+
| `1 - 999` | **Custom colors** | These are the colors that are avalible for the creator to use |
65+
| `1000` | **BG** | This is the color of the background |
66+
| `1001` | **G1** | This is the primary color of the ground |
67+
| `1002` | **LINE** | This is the color of the ground line |
68+
| `1003` | **3DL** | This is the color of the 3D line objects |
69+
| `1004` | **OBJ** | This is the OBJ color |
70+
| `1005` | **P1** | This is the static color channel refering to the primary color of the player's icon |
71+
| `1006` | **P2** | This is the static color channel refering to the secondary color of the player's icon |
72+
| `1007` | **LBG** | This is the static color channel that is a lighter version of `BG` |
73+
| `1009` | **G2** | This is the secondary color of the ground |
74+
| `1010` | **BLACK** | This is the static color channel which is always `r: 0, g: 0, b: 0`. Used in saws that are black by default |
75+
76+
### Undiscovered color channel id's
77+
`WHITE`: Static color that is always `r: 255, g: 255, b: 255`
78+
`LIGHTER`: A lighter version of the primary color in objects. Used in the white small blocks found in `build tab 2 on page 6`.
79+
80+
### Light Background (LBG) calculation
81+
The LBG takes the HSV of background. Subtracts `20` from its saturation, then interpolates from `P1` to the last HSV by a factor of the last HSV's value devided by `100`.
82+
83+
Here is a JavaScript example:
84+
```javascript
85+
function lightBG(bg, p1) {
86+
let hsv = RGBtoHSV(bg);
87+
hsv.s -= 20;
88+
89+
return blendColor( p1, HSVtoRGB(hsv), hsv.v / 100 );
90+
}
91+
```

0 commit comments

Comments
 (0)