-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathpalettefx.h
145 lines (134 loc) · 4.62 KB
/
palettefx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Copyright 2024-2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file palettefx.h
* @brief PaletteFx: Add more colors to your keyboard
*
* While most of QMK's built-in RGB matrix effects are based on a single color
* hue, sampling from a palette of colors allows for more personality. PaletteFx
* is a suite of custom effects for QMK's RGB Matrix in which the effect colors
* are sampled from a palette, aka color gradient or color map.
*
* PaletteFx includes 16 palettes and 6 effects, with the possibility to define
* additional palettes and effects.
*
*
* For full documentation, see
* <https://getreuer.info/posts/keyboards/palettefx>
*/
#pragma once
#include <stdint.h>
#include "color.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Gets the color data for the selected palette. */
const uint16_t* palettefx_get_palette_data(void);
/** Gets the color data for the ith palette. */
const uint16_t* palettefx_get_palette_data_by_index(uint8_t i);
/** Returns the number of palettes. */
uint8_t palettefx_num_palettes(void);
/**
* @brief Computes the interpolated HSV palette color at 0 <= x < 256.
*
* Looks up and linearly interpolates `palette` at 0 <= x < 256. The color
* saturation and value are scaled according to rgb_matrix_config.
*
* @note `palette` must point to a PROGMEM address.
*
* @param palette Pointer to PROGMEM of a size-16 table of HSV16 colors.
* @param x Palette lookup position, a value in 0-255.
* @return HSV color.
*/
hsv_t palettefx_interp_color(const uint16_t* palette, uint8_t x);
// The following enum constants may be used to refer to PaletteFx palettes by
// name. To set a particular palette programmatically, do e.g.
//
// #include "features/palettefx.h"
// void keyboard_post_init_user(void) {
// uint8_t i = PALETTEFX_CARNIVAL; // Set Carnival palette at startup.
// rgb_matrix_sethsv_noeeprom(RGB_MATRIX_HUE_STEP * i, 255, 255);
// }
//
// If you have defined additional palettes in palettefx_user.inc, they may be
// referred to by `PALETTEFX_USER_0`, `PALETTEFX_USER_1`, etc.
enum {
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_AFTERBURN_ENABLE)
PALETTEFX_AFTERBURN,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_AMBER_ENABLE)
PALETTEFX_AMBER,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_BADWOLF_ENABLE)
PALETTEFX_BADWOLF,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_CARNIVAL_ENABLE)
PALETTEFX_CARNIVAL,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_CLASSIC_ENABLE)
PALETTEFX_CLASSIC,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_DRACULA_ENABLE)
PALETTEFX_DRACULA,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_GROOVY_ENABLE)
PALETTEFX_GROOVY,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_NOTPINK_ENABLE)
PALETTEFX_NOTPINK,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_PHOSPHOR_ENABLE)
PALETTEFX_PHOSPHOR,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_POLARIZED_ENABLE)
PALETTEFX_POLARIZED,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_ROSEGOLD_ENABLE)
PALETTEFX_ROSEGOLD,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_SPORT_ENABLE)
PALETTEFX_SPORT,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_SYNTHWAVE_ENABLE)
PALETTEFX_SYNTHWAVE,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_THERMAL_ENABLE)
PALETTEFX_THERMAL,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_VIRIDIS_ENABLE)
PALETTEFX_VIRIDIS,
#endif
#if defined(PALETTEFX_ENABLE_ALL_PALETTES) || defined(PALETTEFX_WATERMELON_ENABLE)
PALETTEFX_WATERMELON,
#endif
PALETTEFX_USER_0,
PALETTEFX_USER_1,
PALETTEFX_USER_2,
PALETTEFX_USER_3,
PALETTEFX_USER_4,
PALETTEFX_USER_5,
PALETTEFX_USER_6,
PALETTEFX_USER_7,
PALETTEFX_USER_8,
PALETTEFX_USER_9,
PALETTEFX_USER_10,
PALETTEFX_USER_11,
PALETTEFX_USER_12,
PALETTEFX_USER_13,
PALETTEFX_USER_14,
PALETTEFX_USER_15,
};
#ifdef __cplusplus
}
#endif