Skip to content

Commit bdf5e51

Browse files
patch raylib's ColorToInt to unsigned int
1 parent 9fcd64b commit bdf5e51

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

examples/raygui/style_selector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pyray import *
2+
import raylib
23

34
screenWidth = 800
45
screenHeight = 480
@@ -40,13 +41,13 @@
4041
match visualStyleActive[0]:
4142
case 0:
4243
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.BACKGROUND_COLOR, 0x000000FF) # black
43-
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.LINE_COLOR, 0x00FF00FF) # green
44+
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.LINE_COLOR, color_to_int(GREEN))
4445
case 1:
4546
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.BACKGROUND_COLOR, 0xF5F5F5FF) # white
46-
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.LINE_COLOR, 0xFF0000FF) # red
47+
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.LINE_COLOR, color_to_int(RED)) # red
4748
case 2:
4849
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.BACKGROUND_COLOR, 0xFF0000FF) # red
49-
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.LINE_COLOR, 0x0000FFFF) # blue
50+
gui_set_style(GuiControl.DEFAULT, GuiDefaultProperty.LINE_COLOR, color_to_int(BLUE)) # blue
5051

5152
prevVisualStyleActive[0] = visualStyleActive[0]
5253

raygui.h.diff

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,25 @@
2929
{
3030
if (!guiStyleLoaded) GuiLoadStyleDefault();
3131
return guiStyle[control*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED) + property];
32+
--- raylib_buggy/src/raylib.h
33+
+++ raylib-c/src/raylib.h
34+
@@ -1436,7 +1436,7 @@ RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle
35+
// Color/pixel related functions
36+
RLAPI bool ColorIsEqual(Color col1, Color col2); // Check if two colors are equal
37+
RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
38+
-RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color (0xRRGGBBAA)
39+
+RLAPI unsigned int ColorToInt(Color color); // Get hexadecimal value for a Color (0xRRGGBBAA)
40+
RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
41+
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
42+
RLAPI Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
43+
--- raylib_buggy/src/rtextures.c
44+
+++ raylib-c/src/rtextures.c
45+
@@ -4832,7 +4832,7 @@ Color Fade(Color color, float alpha)
46+
}
47+
48+
// Get hexadecimal value for a Color
49+
-int ColorToInt(Color color)
50+
+unsigned int ColorToInt(Color color)
51+
{
52+
int result = 0;
53+

raylib/raygui.h.modified

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ typedef enum {
541541
/* Functions defined as 'extern' by default (implicit specifiers)*/ void GuiSetFont(Font font); // Set gui custom font (global state)
542542
/* Functions defined as 'extern' by default (implicit specifiers)*/ Font GuiGetFont(void); // Get gui custom font (global state)
543543
// Style set/get functions
544-
/* Functions defined as 'extern' by default (implicit specifiers)*/ void GuiSetStyle(int control, int property, int value); // Set one style property
545-
/* Functions defined as 'extern' by default (implicit specifiers)*/ int GuiGetStyle(int control, int property); // Get one style property
544+
/* Functions defined as 'extern' by default (implicit specifiers)*/ void GuiSetStyle(int control, int property, unsigned int value); // Set one style property
545+
/* Functions defined as 'extern' by default (implicit specifiers)*/ unsigned int GuiGetStyle(int control, int property); // Get one style property
546546
// Styles loading functions
547547
/* Functions defined as 'extern' by default (implicit specifiers)*/ void GuiLoadStyle(const char *fileName); // Load style file over global style variable (.rgs)
548548
/* Functions defined as 'extern' by default (implicit specifiers)*/ void GuiLoadStyleDefault(void); // Load style default over global style

raylib/raylib.h.modified

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileI
12071207
// Color/pixel related functions
12081208
bool ColorIsEqual(Color col1, Color col2); // Check if two colors are equal
12091209
Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
1210-
int ColorToInt(Color color); // Get hexadecimal value for a Color (0xRRGGBBAA)
1210+
unsigned int ColorToInt(Color color); // Get hexadecimal value for a Color (0xRRGGBBAA)
12111211
Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
12121212
Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
12131213
Vector3 ColorToHSV(Color color); // Get HSV values for a Color, hue [0..360], saturation/value [0..1]

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "5.5.0.3"
1+
__version__ = "5.5.0.4"

0 commit comments

Comments
 (0)