Fixed hsv conversion of black, and fixed default state for editor

main
noah metz 2024-11-17 19:38:13 -07:00
parent ff46b21e11
commit 267da90e91
3 changed files with 30 additions and 16 deletions

@ -501,73 +501,73 @@ VkResult color_ui(ClientContext* context) {
{
.pos = {146, 2},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {168, 2},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {146, 24},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {168, 24},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {146, 46},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {168, 46},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {146, 68},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {168, 68},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {146, 90},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {168, 90},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {146, 112},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
{
.pos = {168, 112},
.size = {20, 20},
.color = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}},
.color = {{0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}, {0, 0, 0, 1}},
.events = UI_EVENT_BUTTON,
},
};
@ -594,13 +594,22 @@ VkResult color_ui(ClientContext* context) {
data->string[4] = '0';
data->string[5] = '0';
data->string[6] = '0';
data->string[7] = '0';
data->string[8] = '0';
data->string[7] = 'F';
data->string[8] = 'F';
data->string[9] = '\0';
data->current[0] = 0;
data->current[1] = 0;
data->current[2] = 0;
data->current[3] = 0;
data->current[3] = 1;
for(uint32_t i = 0; i < 12; i++) {
data->saved[i][0] = 0;
data->saved[i][1] = 0;
data->saved[i][2] = 0;
data->saved[i][3] = 1;
}
UICallbacks callbacks[] = {
{

@ -20,6 +20,11 @@ void rgb_to_hsv(vec3 rgb, double hsv[3]) {
float M = min(rgb[0], min(rgb[1], rgb[2]));
float C = hsv[2] - M;
hsv[1] = C / hsv[2];
if(C == 0) {
hsv[0] = 0;
return;
}
float X;
if(hsv[2] == rgb[0] && M == rgb[2]) {

@ -33,7 +33,7 @@ int main() {
for(int r = 0; r < 256; r++) {
for(int g = 0; g < 256; g++) {
for(int b = 0; b < 256; b++) {
if(test_conv(r, g, b, 0.001) != OK) {
if(test_conv(r, g, b, 0.000001) != OK) {
return -1;
}
}