diff --git a/lib/generate_functions.py b/lib/generate_functions.py index a6773fb..0cee1c1 100755 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -366,6 +366,7 @@ def parse_header(header_name: str, output_file: str, ext_file: str, prefix: str, "ComputeSHA1", "SetWindowIcons", "CheckCollisionPointPoly", + "ColorToInt", "GetFontDefault", "LoadFont", "LoadFontEx", diff --git a/lib/preludes/raylib-prelude.zig b/lib/preludes/raylib-prelude.zig index b5285a5..0d136a0 100644 --- a/lib/preludes/raylib-prelude.zig +++ b/lib/preludes/raylib-prelude.zig @@ -2211,6 +2211,13 @@ pub fn loadRenderTexture(width: i32, height: i32) RaylibError!RenderTexture2D { return if (isValid) render_texture else RaylibError.LoadRenderTexture; } +pub fn colorToInt(color: Color) i32 { + return if (@inComptime()) + (@as(i32, color.r) << 24) | (@as(i32, color.g) << 16) | (@as(i32, color.b) << 8) | @as(i32, color.a) + else + @as(i32, cdef.ColorToInt(color)); +} + /// Get the default Font pub fn getFontDefault() RaylibError!Font { // TODO: GetFontDefault requires SUPPORT_DEFAULT_FONT. Error out if unset. diff --git a/lib/raylib.zig b/lib/raylib.zig index a00acbe..178eadc 100644 --- a/lib/raylib.zig +++ b/lib/raylib.zig @@ -2211,6 +2211,13 @@ pub fn loadRenderTexture(width: i32, height: i32) RaylibError!RenderTexture2D { return if (isValid) render_texture else RaylibError.LoadRenderTexture; } +pub fn colorToInt(color: Color) i32 { + return if (@inComptime()) + (@as(i32, color.r) << 24) | (@as(i32, color.g) << 16) | (@as(i32, color.b) << 8) | @as(i32, color.a) + else + @as(i32, cdef.ColorToInt(color)); +} + /// Get the default Font pub fn getFontDefault() RaylibError!Font { // TODO: GetFontDefault requires SUPPORT_DEFAULT_FONT. Error out if unset. @@ -4218,11 +4225,6 @@ pub fn fade(color: Color, alpha: f32) Color { return cdef.Fade(color, alpha); } -/// Get hexadecimal value for a Color (0xRRGGBBAA) -pub fn colorToInt(color: Color) i32 { - return @as(i32, cdef.ColorToInt(color)); -} - /// Get Color normalized as float [0..1] pub fn colorNormalize(color: Color) Vector4 { return cdef.ColorNormalize(color);