mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-08 19:47:28 +00:00
Perform colorToInt conversion manually during compiletime (#176)
This commit is contained in:
parent
94fa7e23b0
commit
e4d66a8dae
@ -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",
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user