diff --git a/examples/core/2d_camera.zig b/examples/core/2d_camera.zig index 06c16dc..d509216 100755 --- a/examples/core/2d_camera.zig +++ b/examples/core/2d_camera.zig @@ -105,7 +105,7 @@ pub fn main() anyerror!void { rl.drawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, rl.Color.red); rl.drawRectangle(0, screenHeight - 5, screenWidth, 5, rl.Color.red); - rl.drawRectangle(10, 10, 250, 113, rl.fade(rl.Color.sky_blue, 0.5)); + rl.drawRectangle(10, 10, 250, 113, rl.Color.sky_blue.fade(0.5)); rl.drawRectangleLines(10, 10, 250, 113, rl.Color.blue); rl.drawText("Free 2d camera controls:", 20, 20, 10, rl.Color.black); diff --git a/examples/core/3d_camera_first_person.zig b/examples/core/3d_camera_first_person.zig index 34321be..ca6f778 100644 --- a/examples/core/3d_camera_first_person.zig +++ b/examples/core/3d_camera_first_person.zig @@ -64,7 +64,7 @@ pub fn main() anyerror!void { camera.end(); - rl.drawRectangle(10, 10, 220, 70, rl.fade(rl.Color.sky_blue, 0.5)); + rl.drawRectangle(10, 10, 220, 70, rl.Color.sky_blue.fade(0.5)); rl.drawRectangleLines(10, 10, 220, 70, rl.Color.blue); rl.drawText("First person camera default controls:", 20, 20, 10, rl.Color.black); diff --git a/examples/shaders/texture_outline.zig b/examples/shaders/texture_outline.zig index aab46fb..eb73f2d 100644 --- a/examples/shaders/texture_outline.zig +++ b/examples/shaders/texture_outline.zig @@ -14,7 +14,7 @@ pub fn main() anyerror!void { rl.initWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture"); - const texture: rl.Texture2D = rl.loadTexture("resources/textures/fudesumi.png"); + const texture: rl.Texture = rl.Texture.init("resources/textures/fudesumi.png"); const shdrOutline: rl.Shader = rl.loadShader(null, "resources/shaders/glsl330/outline.fs"); diff --git a/examples/textures/sprite_anim.zig b/examples/textures/sprite_anim.zig index 44d0586..c313282 100644 --- a/examples/textures/sprite_anim.zig +++ b/examples/textures/sprite_anim.zig @@ -16,7 +16,7 @@ pub fn main() anyerror!void { rl.initWindow(screenWidth, screenHeight, "raylib [texture] example - sprite anim"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - const scarfy: rl.Texture2D = rl.loadTexture("resources/textures/scarfy.png"); // Texture loading + const scarfy: rl.Texture = rl.Texture.init("resources/textures/scarfy.png"); // Texture loading const position = rl.Vector2.init(350.0, 280.0); var frameRec = rl.Rectangle{ .x = 0.0, .y = 0.0, .width = @intToFloat(f32, @divFloor(scarfy.width, 6)), .height = @intToFloat(f32, scarfy.height) }; diff --git a/lib/preludes/raylib-zig-prelude.zig b/lib/preludes/raylib-zig-prelude.zig index ce10056..c47c405 100755 --- a/lib/preludes/raylib-zig-prelude.zig +++ b/lib/preludes/raylib-zig-prelude.zig @@ -89,6 +89,50 @@ pub const Color = extern struct { pub fn init(r: u8, g: u8, b: u8, a: u8) Color { return Color{ .r = r, .g = g, .b = b, .a = a }; } + + pub fn fromNormalized(normalized: Vector4) Color { + return rl.colorFromNormalized(normalized); + } + + pub fn fromHSV(hue: f32, saturation: f32, value: f32) Color { + return rl.colorFromHSV(hue, saturation, value); + } + + pub fn fromInt(hexValue: u32) Color { + return rl.getColor(hexValue); + } + + pub fn fade(self: Color, a: f32) Color { + return rl.fade(self, a); + } + + pub fn tint(self: Color, t: Color) Color { + return rl.colorTint(self, t); + } + + pub fn normalize(self: Color) Vector4 { + return rl.colorNormalize(self); + } + + pub fn brightness(self: Color, factor: f32) Color { + return rl.colorBrightness(self, factor); + } + + pub fn constrast(self: Color, c: f32) Color { + return rl.colorConstrast(self, c); + } + + pub fn alpha(self: Color, a: f32) Color { + return rl.colorAlpha(self, a); + } + + pub fn toInt(self: Color) Color { + return rl.colorToInt(self); + } + + pub fn toHSV(self: Color) Vector3 { + return rl.colorToHSV(self); + } }; pub const Rectangle = extern struct { diff --git a/lib/raylib-zig.zig b/lib/raylib-zig.zig index 8bad5bc..7a8135e 100644 --- a/lib/raylib-zig.zig +++ b/lib/raylib-zig.zig @@ -89,6 +89,50 @@ pub const Color = extern struct { pub fn init(r: u8, g: u8, b: u8, a: u8) Color { return Color{ .r = r, .g = g, .b = b, .a = a }; } + + pub fn fromNormalized(normalized: Vector4) Color { + return rl.colorFromNormalized(normalized); + } + + pub fn fromHSV(hue: f32, saturation: f32, value: f32) Color { + return rl.colorFromHSV(hue, saturation, value); + } + + pub fn fromInt(hexValue: u32) Color { + return rl.getColor(hexValue); + } + + pub fn fade(self: Color, a: f32) Color { + return rl.fade(self, a); + } + + pub fn tint(self: Color, t: Color) Color { + return rl.colorTint(self, t); + } + + pub fn normalize(self: Color) Vector4 { + return rl.colorNormalize(self); + } + + pub fn brightness(self: Color, factor: f32) Color { + return rl.colorBrightness(self, factor); + } + + pub fn constrast(self: Color, c: f32) Color { + return rl.colorConstrast(self, c); + } + + pub fn alpha(self: Color, a: f32) Color { + return rl.colorAlpha(self, a); + } + + pub fn toInt(self: Color) Color { + return rl.colorToInt(self); + } + + pub fn toHSV(self: Color) Vector3 { + return rl.colorToHSV(self); + } }; pub const Rectangle = extern struct {