|
|
@ -97,12 +97,45 @@ uint32_t add_hex_region(ClientContext* context) {
|
|
|
|
|
|
|
|
|
|
|
|
#define COLOR_PICK_CONTAINER_ID 0x03
|
|
|
|
#define COLOR_PICK_CONTAINER_ID 0x03
|
|
|
|
|
|
|
|
|
|
|
|
void rgb_string_set(ClientContext* context, float r, float g, float b) {
|
|
|
|
void hsv_to_rgb(vec3 hsv, vec3 rgb) {
|
|
|
|
|
|
|
|
float C = hsv[1] * hsv[2];
|
|
|
|
|
|
|
|
float H = hsv[0]*6;
|
|
|
|
|
|
|
|
float X = C * (1 - fabs((H - 2 * floor( H / 2 )) - 1));
|
|
|
|
|
|
|
|
vec4 temp = {0, 0, 0, 0};
|
|
|
|
|
|
|
|
if(0 <= H && H <= 1) {
|
|
|
|
|
|
|
|
temp[0] = C;
|
|
|
|
|
|
|
|
temp[1] = X;
|
|
|
|
|
|
|
|
} else if(1 <= H && H <= 2) {
|
|
|
|
|
|
|
|
temp[0] = X;
|
|
|
|
|
|
|
|
temp[1] = C;
|
|
|
|
|
|
|
|
} else if(2 <= H && H <= 3) {
|
|
|
|
|
|
|
|
temp[1] = C;
|
|
|
|
|
|
|
|
temp[2] = X;
|
|
|
|
|
|
|
|
} else if(3 <= H && H <= 4) {
|
|
|
|
|
|
|
|
temp[1] = X;
|
|
|
|
|
|
|
|
temp[2] = C;
|
|
|
|
|
|
|
|
} else if(4 <= H && H <= 5) {
|
|
|
|
|
|
|
|
temp[0] = X;
|
|
|
|
|
|
|
|
temp[2] = C;
|
|
|
|
|
|
|
|
} else if(5 <= H && H <= 6) {
|
|
|
|
|
|
|
|
temp[0] = C;
|
|
|
|
|
|
|
|
temp[2] = X;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float m = hsv[2] - C;
|
|
|
|
|
|
|
|
rgb[0] = temp[0] + m;
|
|
|
|
|
|
|
|
rgb[1] = temp[1] + m;
|
|
|
|
|
|
|
|
rgb[2] = temp[2] + m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void rgb_string_set(ClientContext* context, vec3 hsv) {
|
|
|
|
|
|
|
|
vec3 rgb;
|
|
|
|
|
|
|
|
hsv_to_rgb(hsv, rgb);
|
|
|
|
char temp[10];
|
|
|
|
char temp[10];
|
|
|
|
snprintf(temp, 10, "#%02x%02x%02x",
|
|
|
|
snprintf(temp, 10, "#%02x%02x%02x",
|
|
|
|
(uint)(r*255),
|
|
|
|
(uint)(rgb[0]*255),
|
|
|
|
(uint)(g*255),
|
|
|
|
(uint)(rgb[1]*255),
|
|
|
|
(uint)(b*255));
|
|
|
|
(uint)(rgb[2]*255));
|
|
|
|
update_ui_string(temp, COLOR_PICK_CONTAINER_ID, 0, 0, context->ui, context->render);
|
|
|
|
update_ui_string(temp, COLOR_PICK_CONTAINER_ID, 0, 0, context->ui, context->render);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -157,7 +190,7 @@ void sv_square_pick(ClientContext* context, float s, float v) {
|
|
|
|
4*sizeof(vec4),
|
|
|
|
4*sizeof(vec4),
|
|
|
|
context->render);
|
|
|
|
context->render);
|
|
|
|
|
|
|
|
|
|
|
|
rgb_string_set(context, select->color[0][0], select->color[0][1], select->color[0][2]);
|
|
|
|
rgb_string_set(context, select->color[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void sv_square_button_callback(void* ptr, float x, float y, int button, int action, int mods) {
|
|
|
|
void sv_square_button_callback(void* ptr, float x, float y, int button, int action, int mods) {
|
|
|
@ -216,7 +249,7 @@ void hue_bar_set(ClientContext* context, float y) {
|
|
|
|
4*sizeof(vec4),
|
|
|
|
4*sizeof(vec4),
|
|
|
|
context->render);
|
|
|
|
context->render);
|
|
|
|
|
|
|
|
|
|
|
|
rgb_string_set(context, select->color[0][0], select->color[0][1], select->color[0][2]);
|
|
|
|
rgb_string_set(context, select->color[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hue_bar_scroll_callback(void* ptr, double x, double y) {
|
|
|
|
void hue_bar_scroll_callback(void* ptr, double x, double y) {
|
|
|
|