added documentation on Hue control issues with GuiColorPicker (#373)

* added documentation on Hue control issues with GuiColorPicker

* Moved Color Picker doc from function signature to definition
This commit is contained in:
Lieven Petersen 2024-02-15 22:46:55 +01:00 committed by GitHub
parent a3bbc8408b
commit 77891affb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3561,6 +3561,7 @@ int GuiColorBarHue(Rectangle bounds, const char *text, float *hue)
// float GuiColorBarAlpha(Rectangle bounds, float alpha) // float GuiColorBarAlpha(Rectangle bounds, float alpha)
// float GuiColorBarHue(Rectangle bounds, float value) // float GuiColorBarHue(Rectangle bounds, float value)
// NOTE: bounds define GuiColorPanel() size // NOTE: bounds define GuiColorPanel() size
// NOTE: this picker converts RGB to HSV, which can cause the Hue control to jump. If you have this problem, consider using the HSV variant instead
int GuiColorPicker(Rectangle bounds, const char *text, Color *color) int GuiColorPicker(Rectangle bounds, const char *text, Color *color)
{ {
int result = 0; int result = 0;
@ -3573,6 +3574,7 @@ int GuiColorPicker(Rectangle bounds, const char *text, Color *color)
Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height }; Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
//Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) }; //Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
// NOTE: this conversion can cause low hue-resolution, if the r, g and b value are very similar, which causes the hue bar to shift around when only the GuiColorPanel is used.
Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f }); Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ (*color).r/255.0f, (*color).g/255.0f, (*color).b/255.0f });
GuiColorBarHue(boundsHue, NULL, &hsv.x); GuiColorBarHue(boundsHue, NULL, &hsv.x);