From d4fc514d54a3b37b9b3e4f4983f611c3469e8c2a Mon Sep 17 00:00:00 2001 From: Mike Will Date: Wed, 12 Mar 2025 16:21:15 -0400 Subject: [PATCH] examples: Use decl literals (#221) --- README.md | 4 +- examples/audio/module_playing.zig | 32 +++++------ examples/audio/music_stream.zig | 18 +++---- examples/audio/raw_stream.zig | 8 +-- examples/audio/sound_loading.zig | 10 ++-- examples/core/2d_camera.zig | 42 +++++++-------- examples/core/2d_camera_mouse_zoom.zig | 10 ++-- examples/core/3d_camera_first_person.zig | 32 +++++------ examples/core/3d_camera_free.zig | 26 ++++----- examples/core/3d_picking.zig | 30 +++++------ examples/core/basic_screen_manager.zig | 24 ++++----- examples/core/basic_window.zig | 4 +- examples/core/basic_window_web.zig | 4 +- examples/core/input_keys.zig | 6 +-- examples/core/input_mouse.zig | 10 ++-- examples/core/input_mouse_wheel.zig | 8 +-- examples/core/input_multitouch.zig | 18 +++---- examples/core/window_flags.zig | 44 +++++++-------- examples/models/models_heightmap.zig | 10 ++-- examples/shaders/raymarching.zig | 6 +-- examples/shaders/texture_outline.zig | 10 ++-- examples/shapes/basic_shapes.zig | 28 +++++----- examples/shapes/bouncing_ball.zig | 8 +-- examples/shapes/collision_area.zig | 18 +++---- examples/shapes/colors_palette.zig | 54 +++++++++---------- examples/shapes/draw_circle_sector.zig | 14 ++--- examples/shapes/draw_rectangle_rounded.zig | 16 +++--- examples/shapes/draw_ring.zig | 16 +++--- examples/shapes/following_eyes.zig | 14 ++--- examples/shapes/lines_bezier.zig | 10 ++-- examples/shapes/logo_raylib.zig | 6 +-- examples/shapes/logo_raylib_anim.zig | 30 +++++------ examples/shapes/rectangle_scaling.zig | 10 ++-- examples/text/text_format_text.zig | 10 ++-- examples/text/text_writing_anim.zig | 4 +- examples/textures/sprite_anim.zig | 24 ++++----- .../textures_background_scrolling.zig | 28 +++++----- 37 files changed, 323 insertions(+), 323 deletions(-) diff --git a/README.md b/README.md index ca3eed1..5e24b26 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,9 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray); + rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/audio/module_playing.zig b/examples/audio/module_playing.zig index 9016557..b2b25ef 100644 --- a/examples/audio/module_playing.zig +++ b/examples/audio/module_playing.zig @@ -13,7 +13,7 @@ const CircleWave = struct { const screenWidth = 800; const screenHeight = 450; -const colors = [14]rl.Color{ rl.Color.orange, rl.Color.red, rl.Color.gold, rl.Color.lime, rl.Color.blue, rl.Color.violet, rl.Color.brown, rl.Color.light_gray, rl.Color.pink, rl.Color.yellow, rl.Color.green, rl.Color.sky_blue, rl.Color.purple, rl.Color.beige }; +const colors = [14]rl.Color{ .orange, .red, .gold, .lime, .blue, .violet, .brown, .light_gray, .pink, .yellow, .green, .sky_blue, .purple, .beige }; //------------------------------------------------------------------------------------ // Program main entry point @@ -57,14 +57,14 @@ pub fn main() !void { rl.updateMusicStream(music); // Update music buffer with new stream data // Restart music playing (stop and play) - if (rl.isKeyPressed(rl.KeyboardKey.space)) { + if (rl.isKeyPressed(.space)) { rl.stopMusicStream(music); rl.playMusicStream(music); pause = false; } // Pause/Resume music playing - if (rl.isKeyPressed(rl.KeyboardKey.p)) { + if (rl.isKeyPressed(.p)) { pause = !pause; if (pause) { @@ -74,9 +74,9 @@ pub fn main() !void { } } - if (rl.isKeyDown(rl.KeyboardKey.down)) { + if (rl.isKeyDown(.down)) { pitch -= 0.01; - } else if (rl.isKeyDown(rl.KeyboardKey.up)) { + } else if (rl.isKeyDown(.up)) { pitch += 0.01; } @@ -103,24 +103,24 @@ pub fn main() !void { //---------------------------------------------------------------------------------- rl.beginDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); for (circles) |circle| { - rl.drawCircleV(circle.position, circle.radius, rl.fade(circle.color, circle.alpha)); + rl.drawCircleV(circle.position, circle.radius, .fade(circle.color, circle.alpha)); } // Draw time bar - rl.drawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, rl.Color.light_gray); - rl.drawRectangle(20, screenHeight - 20 - 12, @intFromFloat(timePlayed), 12, rl.Color.maroon); - rl.drawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, rl.Color.gray); + rl.drawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, .light_gray); + rl.drawRectangle(20, screenHeight - 20 - 12, @intFromFloat(timePlayed), 12, .maroon); + rl.drawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, .gray); // Draw help instructions - rl.drawRectangle(20, 20, 425, 145, rl.Color.white); - rl.drawRectangleLines(20, 20, 425, 145, rl.Color.gray); - rl.drawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, rl.Color.black); - rl.drawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, rl.Color.black); - rl.drawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, rl.Color.black); - rl.drawText(rl.textFormat("SPEED: %f", .{pitch}), 40, 130, 20, rl.Color.maroon); + rl.drawRectangle(20, 20, 425, 145, .white); + rl.drawRectangleLines(20, 20, 425, 145, .gray); + rl.drawText("PRESS SPACE TO RESTART MUSIC", 40, 40, 20, .black); + rl.drawText("PRESS P TO PAUSE/RESUME", 40, 70, 20, .black); + rl.drawText("PRESS UP/DOWN TO CHANGE SPEED", 40, 100, 20, .black); + rl.drawText(rl.textFormat("SPEED: %f", .{pitch}), 40, 130, 20, .maroon); rl.endDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/audio/music_stream.zig b/examples/audio/music_stream.zig index 66eef97..160d6dd 100644 --- a/examples/audio/music_stream.zig +++ b/examples/audio/music_stream.zig @@ -34,13 +34,13 @@ pub fn main() !void { rl.updateMusicStream(music); // Update music buffer with new stream data // Restart music playing (stop and play) - if (rl.isKeyPressed(rl.KeyboardKey.space)) { + if (rl.isKeyPressed(.space)) { rl.stopMusicStream(music); rl.playMusicStream(music); } // Pause/Resume music playing - if (rl.isKeyPressed(rl.KeyboardKey.p)) { + if (rl.isKeyPressed(.p)) { pause = !pause; if (pause) { @@ -63,16 +63,16 @@ pub fn main() !void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, rl.Color.light_gray); + rl.drawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, .light_gray); - rl.drawRectangle(200, 200, 400, 12, rl.Color.light_gray); - rl.drawRectangle(200, 200, @intFromFloat(timePlayed * 400), 12, rl.Color.maroon); - rl.drawRectangleLines(200, 200, 400, 12, rl.Color.gray); + rl.drawRectangle(200, 200, 400, 12, .light_gray); + rl.drawRectangle(200, 200, @intFromFloat(timePlayed * 400), 12, .maroon); + rl.drawRectangleLines(200, 200, 400, 12, .gray); - rl.drawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, rl.Color.light_gray); - rl.drawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, rl.Color.light_gray); + rl.drawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, .light_gray); + rl.drawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, .light_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/audio/raw_stream.zig b/examples/audio/raw_stream.zig index b95ee63..b540ddc 100644 --- a/examples/audio/raw_stream.zig +++ b/examples/audio/raw_stream.zig @@ -111,12 +111,12 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); rl.drawText(rl.textFormat("sine frequency: %i", .{@as(i32, @intFromFloat(frequency))}), - rl.getScreenWidth() - 220, 10, 20, rl.Color.red); + rl.getScreenWidth() - 220, 10, 20, .red); rl.drawText("click mouse button to change frequency or pan", - 10, 10, 20, rl.Color.dark_gray); + 10, 10, 20, .dark_gray); // Draw the current buffer state proportionate to the screen for (0..screenWidth) |i| { @@ -124,7 +124,7 @@ pub fn main() anyerror!void { const y: f32 = @floatFromInt(data[@divFloor(i * MAX_SAMPLES, screenWidth)]); position.y = 250 + 50 * y / 32000; - rl.drawPixelV(position, rl.Color.red); + rl.drawPixelV(position, .red); } //---------------------------------------------------------------------------------- } diff --git a/examples/audio/sound_loading.zig b/examples/audio/sound_loading.zig index faba5b8..a74cb70 100644 --- a/examples/audio/sound_loading.zig +++ b/examples/audio/sound_loading.zig @@ -28,8 +28,8 @@ pub fn main() !void { { // Update //---------------------------------------------------------------------------------- - if (rl.isKeyPressed(rl.KeyboardKey.space)) rl.playSound(fxWav); // Play WAV sound - if (rl.isKeyPressed(rl.KeyboardKey.enter)) rl.playSound(fxOgg); // Play OGG sound + if (rl.isKeyPressed(.space)) rl.playSound(fxWav); // Play WAV sound + if (rl.isKeyPressed(.enter)) rl.playSound(fxOgg); // Play OGG sound //---------------------------------------------------------------------------------- // Draw @@ -37,10 +37,10 @@ pub fn main() !void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, rl.Color.light_gray); - rl.drawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, rl.Color.light_gray); + rl.drawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, .light_gray); + rl.drawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, .light_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/2d_camera.zig b/examples/core/2d_camera.zig index 0388ff8..69b97c9 100644 --- a/examples/core/2d_camera.zig +++ b/examples/core/2d_camera.zig @@ -27,7 +27,7 @@ pub fn main() anyerror!void { spacing += @as(i32, @intFromFloat(buildings[i].width)); - buildColors[i] = rl.Color.init( + buildColors[i] = .init( @as(u8, @intCast(rl.getRandomValue(200, 240))), @as(u8, @intCast(rl.getRandomValue(200, 240))), @as(u8, @intCast(rl.getRandomValue(200, 250))), @@ -36,8 +36,8 @@ pub fn main() anyerror!void { } var camera = rl.Camera2D{ - .target = rl.Vector2.init(player.x + 20, player.y + 20), - .offset = rl.Vector2.init(screenWidth / 2, screenHeight / 2), + .target = .init(player.x + 20, player.y + 20), + .offset = .init(screenWidth / 2, screenHeight / 2), .rotation = 0, .zoom = 1, }; @@ -58,7 +58,7 @@ pub fn main() anyerror!void { } // Camera target follows player - camera.target = rl.Vector2.init(player.x + 20, player.y + 20); + camera.target = .init(player.x + 20, player.y + 20); // Camera rotation controls if (rl.isKeyDown(.a)) { @@ -87,51 +87,51 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); { camera.begin(); defer camera.end(); - rl.drawRectangle(-6000, 320, 13000, 8000, rl.Color.dark_gray); + rl.drawRectangle(-6000, 320, 13000, 8000, .dark_gray); for (buildings, 0..) |building, i| { rl.drawRectangleRec(building, buildColors[i]); } - rl.drawRectangleRec(player, rl.Color.red); + rl.drawRectangleRec(player, .red); rl.drawLine( @as(i32, @intFromFloat(camera.target.x)), -screenHeight * 10, @as(i32, @intFromFloat(camera.target.x)), screenHeight * 10, - rl.Color.green, + .green, ); rl.drawLine( -screenWidth * 10, @as(i32, @intFromFloat(camera.target.y)), screenWidth * 10, @as(i32, @intFromFloat(camera.target.y)), - rl.Color.green, + .green, ); } - rl.drawText("SCREEN AREA", 640, 10, 20, rl.Color.red); + rl.drawText("SCREEN AREA", 640, 10, 20, .red); - rl.drawRectangle(0, 0, screenWidth, 5, rl.Color.red); - rl.drawRectangle(0, 5, 5, screenHeight - 10, rl.Color.red); - rl.drawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, rl.Color.red); - rl.drawRectangle(0, screenHeight - 5, screenWidth, 5, rl.Color.red); + rl.drawRectangle(0, 0, screenWidth, 5, .red); + rl.drawRectangle(0, 5, 5, screenHeight - 10, .red); + rl.drawRectangle(screenWidth - 5, 5, 5, screenHeight - 10, .red); + rl.drawRectangle(0, screenHeight - 5, screenWidth, 5, .red); - rl.drawRectangle(10, 10, 250, 113, rl.Color.sky_blue.fade(0.5)); - rl.drawRectangleLines(10, 10, 250, 113, rl.Color.blue); + rl.drawRectangle(10, 10, 250, 113, .fade(.sky_blue, 0.5)); + rl.drawRectangleLines(10, 10, 250, 113, .blue); - rl.drawText("Free 2d camera controls:", 20, 20, 10, rl.Color.black); - rl.drawText("- Right/Left to move Offset", 40, 40, 10, rl.Color.dark_gray); - rl.drawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, rl.Color.dark_gray); - rl.drawText("- A / S to Rotate", 40, 80, 10, rl.Color.dark_gray); - rl.drawText("- R to reset Zoom and Rotation", 40, 100, 10, rl.Color.dark_gray); + rl.drawText("Free 2d camera controls:", 20, 20, 10, .black); + rl.drawText("- Right/Left to move Offset", 40, 40, 10, .dark_gray); + rl.drawText("- Mouse Wheel to Zoom in-out", 40, 60, 10, .dark_gray); + rl.drawText("- A / S to Rotate", 40, 80, 10, .dark_gray); + rl.drawText("- R to reset Zoom and Rotation", 40, 100, 10, .dark_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/2d_camera_mouse_zoom.zig b/examples/core/2d_camera_mouse_zoom.zig index dc104e8..4e57325 100644 --- a/examples/core/2d_camera_mouse_zoom.zig +++ b/examples/core/2d_camera_mouse_zoom.zig @@ -91,7 +91,7 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); { camera.begin(); @@ -103,14 +103,14 @@ pub fn main() anyerror!void { rl.drawGrid(100, 50); rl.gl.rlPopMatrix(); - rl.drawCircle(screenWidth / 2, screenHeight / 2, 50, rl.Color.maroon); + rl.drawCircle(screenWidth / 2, screenHeight / 2, 50, .maroon); } - rl.drawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, rl.Color.dark_gray); + rl.drawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, .dark_gray); if (zoomMode == 0) { - rl.drawText("Mouse right button drag to move, mouse wheel to zoom", 20, 50, 20, rl.Color.dark_gray); + rl.drawText("Mouse right button drag to move, mouse wheel to zoom", 20, 50, 20, .dark_gray); } else { - rl.drawText("Mouse right button drag to move, mouse press and move to zoom", 20, 50, 20, rl.Color.dark_gray); + rl.drawText("Mouse right button drag to move, mouse press and move to zoom", 20, 50, 20, .dark_gray); } //---------------------------------------------------------------------------------- diff --git a/examples/core/3d_camera_first_person.zig b/examples/core/3d_camera_first_person.zig index d855576..5d47b5a 100644 --- a/examples/core/3d_camera_first_person.zig +++ b/examples/core/3d_camera_first_person.zig @@ -14,9 +14,9 @@ pub fn main() anyerror!void { defer rl.closeWindow(); // Close window and OpenGL context var camera = rl.Camera3D{ - .position = rl.Vector3.init(4, 2, 4), - .target = rl.Vector3.init(0, 1.8, 0), - .up = rl.Vector3.init(0, 1, 0), + .position = .init(4, 2, 4), + .target = .init(0, 1.8, 0), + .up = .init(0, 1, 0), .fovy = 60, .projection = .perspective, }; @@ -27,12 +27,12 @@ pub fn main() anyerror!void { for (0..heights.len) |i| { heights[i] = @as(f32, @floatFromInt(rl.getRandomValue(1, 12))); - positions[i] = rl.Vector3.init( + positions[i] = .init( @as(f32, @floatFromInt(rl.getRandomValue(-15, 15))), heights[i] / 2.0, @as(f32, @floatFromInt(rl.getRandomValue(-15, 15))), ); - colors[i] = rl.Color.init( + colors[i] = .init( @as(u8, @intCast(rl.getRandomValue(20, 255))), @as(u8, @intCast(rl.getRandomValue(10, 55))), 30, @@ -56,31 +56,31 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); { camera.begin(); defer camera.end(); // Draw ground - rl.drawPlane(rl.Vector3.init(0, 0, 0), rl.Vector2.init(32, 32), rl.Color.light_gray); - rl.drawCube(rl.Vector3.init(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Color.blue); // Draw a blue wall - rl.drawCube(rl.Vector3.init(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, rl.Color.lime); // Draw a green wall - rl.drawCube(rl.Vector3.init(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, rl.Color.gold); // Draw a yellow wall + rl.drawPlane(.init(0, 0, 0), .init(32, 32), .light_gray); + rl.drawCube(.init(-16.0, 2.5, 0.0), 1.0, 5.0, 32.0, .blue); // Draw a blue wall + rl.drawCube(.init(16.0, 2.5, 0.0), 1.0, 5.0, 32.0, .lime); // Draw a green wall + rl.drawCube(.init(0.0, 2.5, 16.0), 32.0, 5.0, 1.0, .gold); // Draw a yellow wall // Draw some cubes around for (heights, 0..) |height, i| { rl.drawCube(positions[i], 2.0, height, 2.0, colors[i]); - rl.drawCubeWires(positions[i], 2.0, height, 2.0, rl.Color.maroon); + rl.drawCubeWires(positions[i], 2.0, height, 2.0, .maroon); } } - rl.drawRectangle(10, 10, 220, 70, rl.Color.sky_blue.fade(0.5)); - rl.drawRectangleLines(10, 10, 220, 70, rl.Color.blue); + rl.drawRectangle(10, 10, 220, 70, .fade(.sky_blue, 0.5)); + rl.drawRectangleLines(10, 10, 220, 70, .blue); - rl.drawText("First person camera default controls:", 20, 20, 10, rl.Color.black); - rl.drawText("- Move with keys: W, A, S, D", 40, 40, 10, rl.Color.dark_gray); - rl.drawText("- Mouse move to look around", 40, 60, 10, rl.Color.dark_gray); + rl.drawText("First person camera default controls:", 20, 20, 10, .black); + rl.drawText("- Move with keys: W, A, S, D", 40, 40, 10, .dark_gray); + rl.drawText("- Mouse move to look around", 40, 60, 10, .dark_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/3d_camera_free.zig b/examples/core/3d_camera_free.zig index 00d843e..dac977b 100644 --- a/examples/core/3d_camera_free.zig +++ b/examples/core/3d_camera_free.zig @@ -16,9 +16,9 @@ pub fn main() anyerror!void { // Define the camera to look into our 3d world var camera = rl.Camera{ - .position = rl.Vector3.init(10, 10, 10), - .target = rl.Vector3.init(0, 0, 0), - .up = rl.Vector3.init(0, 1, 0), + .position = .init(10, 10, 10), + .target = .init(0, 0, 0), + .up = .init(0, 1, 0), .fovy = 45, .projection = .perspective, }; @@ -36,7 +36,7 @@ pub fn main() anyerror!void { camera.update(.free); if (rl.isKeyPressed(.z)) { - camera.target = rl.Vector3.init(0, 0, 0); + camera.target = .init(0, 0, 0); } //----------------------------------------------------------------------------- @@ -45,25 +45,25 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); { camera.begin(); defer camera.end(); - rl.drawCube(cubePosition, 2, 2, 2, rl.Color.red); - rl.drawCubeWires(cubePosition, 2, 2, 2, rl.Color.maroon); + rl.drawCube(cubePosition, 2, 2, 2, .red); + rl.drawCubeWires(cubePosition, 2, 2, 2, .maroon); rl.drawGrid(10, 1); } - rl.drawRectangle(10, 10, 320, 93, rl.Color.fade(rl.Color.sky_blue, 0.5)); - rl.drawRectangleLines(10, 10, 320, 93, rl.Color.blue); + rl.drawRectangle(10, 10, 320, 93, .fade(.sky_blue, 0.5)); + rl.drawRectangleLines(10, 10, 320, 93, .blue); - rl.drawText("Free camera default controls:", 20, 20, 10, rl.Color.black); - rl.drawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, rl.Color.dark_gray); - rl.drawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, rl.Color.dark_gray); - rl.drawText("- Z to zoom to (0, 0, 0)", 40, 80, 10, rl.Color.dark_gray); + rl.drawText("Free camera default controls:", 20, 20, 10, .black); + rl.drawText("- Mouse Wheel to Zoom in-out", 40, 40, 10, .dark_gray); + rl.drawText("- Mouse Wheel Pressed to Pan", 40, 60, 10, .dark_gray); + rl.drawText("- Z to zoom to (0, 0, 0)", 40, 80, 10, .dark_gray); //----------------------------------------------------------------------------- } } diff --git a/examples/core/3d_picking.zig b/examples/core/3d_picking.zig index e690954..3c7e61e 100644 --- a/examples/core/3d_picking.zig +++ b/examples/core/3d_picking.zig @@ -11,9 +11,9 @@ pub fn main() anyerror!void { // Define the camera to look into our 3d world var camera = rl.Camera{ - .position = rl.Vector3.init(10, 10, 10), - .target = rl.Vector3.init(0, 0, 0), - .up = rl.Vector3.init(0, 1, 0), + .position = .init(10, 10, 10), + .target = .init(0, 0, 0), + .up = .init(0, 1, 0), .fovy = 45, .projection = .perspective, }; @@ -44,8 +44,8 @@ pub fn main() anyerror!void { // Check collision between ray and box collision = rl.getRayCollisionBox(ray, rl.BoundingBox{ - .max = rl.Vector3.init(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2), - .min = rl.Vector3.init(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2), + .max = .init(cubePosition.x - cubeSize.x / 2, cubePosition.y - cubeSize.y / 2, cubePosition.z - cubeSize.z / 2), + .min = .init(cubePosition.x + cubeSize.x / 2, cubePosition.y + cubeSize.y / 2, cubePosition.z + cubeSize.z / 2), }); } else collision.hit = false; } @@ -56,33 +56,33 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); { camera.begin(); defer camera.end(); if (collision.hit) { - rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.red); - rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.maroon); + rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .red); + rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .maroon); - rl.drawCubeWires(cubePosition, cubeSize.x + 0.2, cubeSize.y + 0.2, cubeSize.z + 0.2, rl.Color.green); + rl.drawCubeWires(cubePosition, cubeSize.x + 0.2, cubeSize.y + 0.2, cubeSize.z + 0.2, .green); } else { - rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.gray); - rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, rl.Color.dark_gray); + rl.drawCube(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .gray); + rl.drawCubeWires(cubePosition, cubeSize.x, cubeSize.y, cubeSize.z, .dark_gray); } - rl.drawRay(ray, rl.Color.maroon); + rl.drawRay(ray, .maroon); rl.drawGrid(10, 1); } - rl.drawText("Try clicking on the box with your mouse!", 240, 10, 20, rl.Color.dark_gray); + rl.drawText("Try clicking on the box with your mouse!", 240, 10, 20, .dark_gray); if (collision.hit) { - rl.drawText("BOX SELECTED", @divTrunc((screenWidth - rl.measureText("BOX SELECTED", 30)), 2), screenHeight * 0.1, 30, rl.Color.green); + rl.drawText("BOX SELECTED", @divTrunc((screenWidth - rl.measureText("BOX SELECTED", 30)), 2), screenHeight * 0.1, 30, .green); } - rl.drawText("Right click mouse to toggle camera controls", 10, 430, 10, rl.Color.gray); + rl.drawText("Right click mouse to toggle camera controls", 10, 430, 10, .gray); rl.drawFPS(10, 10); } diff --git a/examples/core/basic_screen_manager.zig b/examples/core/basic_screen_manager.zig index 14e072a..2664693 100644 --- a/examples/core/basic_screen_manager.zig +++ b/examples/core/basic_screen_manager.zig @@ -85,18 +85,18 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); switch (current_screen) { .logo => { // TODO: Draw `logo` state here! - rl.drawText("LOGO SCREEN", 20, 20, 40, rl.Color.light_gray); + rl.drawText("LOGO SCREEN", 20, 20, 40, .light_gray); rl.drawText( "WAIT for 2 SECONDS...", 290, 220, 20, - rl.Color.gray, + .gray, ); }, .title => { @@ -106,21 +106,21 @@ pub fn main() anyerror!void { 0, screen_width, screen_height, - rl.Color.green, + .green, ); rl.drawText( "TITLE SCREEN", 20, 20, 40, - rl.Color.dark_green, + .dark_green, ); rl.drawText( "PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, - rl.Color.dark_green, + .dark_green, ); }, .gameplay => { @@ -130,15 +130,15 @@ pub fn main() anyerror!void { 0, screen_width, screen_height, - rl.Color.purple, + .purple, ); - rl.drawText("GAMEPLAY SCREEN", 20, 20, 40, rl.Color.maroon); + rl.drawText("GAMEPLAY SCREEN", 20, 20, 40, .maroon); rl.drawText( "PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, - rl.Color.maroon, + .maroon, ); }, .ending => { @@ -148,21 +148,21 @@ pub fn main() anyerror!void { 0, screen_width, screen_height, - rl.Color.blue, + .blue, ); rl.drawText( "ENDING SCREEN", 20, 20, 40, - rl.Color.dark_blue, + .dark_blue, ); rl.drawText( "PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, - rl.Color.dark_blue, + .dark_blue, ); }, } diff --git a/examples/core/basic_window.zig b/examples/core/basic_window.zig index b2529e9..7e2e133 100644 --- a/examples/core/basic_window.zig +++ b/examples/core/basic_window.zig @@ -26,9 +26,9 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray); + rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/basic_window_web.zig b/examples/core/basic_window_web.zig index 0483dfb..66e85f7 100644 --- a/examples/core/basic_window_web.zig +++ b/examples/core/basic_window_web.zig @@ -47,8 +47,8 @@ fn updateDrawFrame() void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray); + rl.drawText("Congrats! You created your first window!", 190, 200, 20, .light_gray); //---------------------------------------------------------------------------------- } diff --git a/examples/core/input_keys.zig b/examples/core/input_keys.zig index f9df6c9..e1d8c93 100644 --- a/examples/core/input_keys.zig +++ b/examples/core/input_keys.zig @@ -40,11 +40,11 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawText("move the ball with arrow keys", 10, 10, 20, rl.Color.dark_gray); + rl.drawText("move the ball with arrow keys", 10, 10, 20, .dark_gray); - rl.drawCircleV(ballPosition, 50, rl.Color.maroon); + rl.drawCircleV(ballPosition, 50, .maroon); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/input_mouse.zig b/examples/core/input_mouse.zig index 4d13f73..1720e61 100644 --- a/examples/core/input_mouse.zig +++ b/examples/core/input_mouse.zig @@ -26,11 +26,11 @@ pub fn main() anyerror!void { ballPosition.y = @as(f32, @floatFromInt(rl.getMouseY())); if (rl.isMouseButtonPressed(.left)) { - ballColor = rl.Color.maroon; + ballColor = .maroon; } else if (rl.isMouseButtonPressed(.middle)) { - ballColor = rl.Color.lime; + ballColor = .lime; } else if (rl.isMouseButtonPressed(.right)) { - ballColor = rl.Color.dark_blue; + ballColor = .dark_blue; } //---------------------------------------------------------------------------------- @@ -39,11 +39,11 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); rl.drawCircleV(ballPosition, 40, ballColor); - rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, rl.Color.dark_gray); + rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, .dark_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/input_mouse_wheel.zig b/examples/core/input_mouse_wheel.zig index 86f88b7..079701c 100644 --- a/examples/core/input_mouse_wheel.zig +++ b/examples/core/input_mouse_wheel.zig @@ -30,18 +30,18 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawRectangle(screenWidth / 2 - 40, @as(i32, @intFromFloat(boxPositionY)), 80, 80, rl.Color.maroon); + rl.drawRectangle(screenWidth / 2 - 40, @as(i32, @intFromFloat(boxPositionY)), 80, 80, .maroon); - rl.drawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, rl.Color.gray); + rl.drawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, .gray); rl.drawText( rl.textFormat("Box position Y: %03i", .{@as(i32, @intFromFloat(boxPositionY))}), 10, 40, 20, - rl.Color.light_gray, + .light_gray, ); //---------------------------------------------------------------------------------- } diff --git a/examples/core/input_multitouch.zig b/examples/core/input_multitouch.zig index fe9a124..4e27ad5 100644 --- a/examples/core/input_multitouch.zig +++ b/examples/core/input_multitouch.zig @@ -26,16 +26,16 @@ pub fn main() anyerror!void { //---------------------------------------------------------------------------------- ballPosition = rl.getMousePosition(); - ballColor = rl.Color.beige; + ballColor = .beige; if (rl.isMouseButtonDown(.left)) { - ballColor = rl.Color.maroon; + ballColor = .maroon; } if (rl.isMouseButtonDown(.middle)) { - ballColor = rl.Color.lime; + ballColor = .lime; } if (rl.isMouseButtonDown(.right)) { - ballColor = rl.Color.dark_blue; + ballColor = .dark_blue; } if (rl.isMouseButtonPressed(.left)) { @@ -58,7 +58,7 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); const nums = [_]i32{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; for (nums) |i| { @@ -68,13 +68,13 @@ pub fn main() anyerror!void { if ((touchPosition.x >= 0) and (touchPosition.y >= 0)) { // Draw circle and touch index number - rl.drawCircleV(touchPosition, 34, rl.Color.orange); + rl.drawCircleV(touchPosition, 34, .orange); rl.drawText( rl.textFormat("%d", .{i}), @as(i32, @intFromFloat(touchPosition.x)) - 10, @as(i32, @intFromFloat(touchPosition.y)) - 70, 40, - rl.Color.black, + .black, ); } } @@ -82,8 +82,8 @@ pub fn main() anyerror!void { // Draw the normal mouse location rl.drawCircleV(ballPosition, 30 + (touchCounter * 3), ballColor); - rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, rl.Color.dark_gray); - rl.drawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, rl.Color.dark_gray); + rl.drawText("move ball with mouse and click mouse button to change color", 10, 10, 20, .dark_gray); + rl.drawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, .dark_gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/core/window_flags.zig b/examples/core/window_flags.zig index 5c8b6fc..2ad7a9f 100644 --- a/examples/core/window_flags.zig +++ b/examples/core/window_flags.zig @@ -149,17 +149,17 @@ pub fn main() anyerror!void { defer rl.endDrawing(); if (rl.isWindowState(rl.ConfigFlags { .window_transparent = true })) { - rl.clearBackground(rl.Color.blank); - } else rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.blank); + } else rl.clearBackground(.ray_white); - rl.drawCircleV(ball_position, ball_radius, rl.Color.maroon); + rl.drawCircleV(ball_position, ball_radius, .maroon); rl.drawRectangleLinesEx( - rl.Rectangle.init(0, 0, @floatFromInt(rl.getScreenWidth()), @floatFromInt(rl.getScreenHeight())), + .init(0, 0, @floatFromInt(rl.getScreenWidth()), @floatFromInt(rl.getScreenHeight())), 4, - rl.Color.ray_white, + .ray_white, ); - rl.drawCircleV(rl.getMousePosition(), 10, rl.Color.dark_blue); + rl.drawCircleV(rl.getMousePosition(), 10, .dark_blue); rl.drawFPS(10, 10); @@ -168,7 +168,7 @@ pub fn main() anyerror!void { 10, 40, 10, - rl.Color.green, + .green, ); // Draw window state info @@ -177,7 +177,7 @@ pub fn main() anyerror!void { 10, 60, 10, - rl.Color.gray, + .gray, ); rl.drawText( rl.textFormat("[F] flag_fullscreen_mode: %d", .{ @@ -186,7 +186,7 @@ pub fn main() anyerror!void { 10, 80, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[R] flag_window_resizable: %d", .{ @@ -195,7 +195,7 @@ pub fn main() anyerror!void { 10, 100, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[D] flag_window_undecorated: %d", .{ @@ -204,7 +204,7 @@ pub fn main() anyerror!void { 10, 120, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[H] flag_window_hidden: %d", .{ @@ -213,7 +213,7 @@ pub fn main() anyerror!void { 10, 140, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[N] flag_window_minimized: %d", .{ @@ -222,7 +222,7 @@ pub fn main() anyerror!void { 10, 160, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[M] flag_window_maximized: %d", .{ @@ -231,7 +231,7 @@ pub fn main() anyerror!void { 10, 180, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[U] flag_window_unfocused: %d", .{ @@ -240,7 +240,7 @@ pub fn main() anyerror!void { 10, 200, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[T] flag_window_topmost: %d", .{ @@ -249,7 +249,7 @@ pub fn main() anyerror!void { 10, 220, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[A] flag_window_always_run: %d", .{ @@ -258,7 +258,7 @@ pub fn main() anyerror!void { 10, 240, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("[V] flag_vsync_hint: %d", .{ @@ -267,7 +267,7 @@ pub fn main() anyerror!void { 10, 260, 10, - rl.Color.lime, + .lime, ); rl.drawText( @@ -275,7 +275,7 @@ pub fn main() anyerror!void { 10, 300, 10, - rl.Color.gray, + .gray, ); rl.drawText( rl.textFormat("flag_window_highdpi: %d", .{ @@ -284,7 +284,7 @@ pub fn main() anyerror!void { 10, 320, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("flag_window_transparent: %d", .{ @@ -293,7 +293,7 @@ pub fn main() anyerror!void { 10, 340, 10, - rl.Color.lime, + .lime, ); rl.drawText( rl.textFormat("flag_msaa_4x_hint: %d", .{ @@ -302,7 +302,7 @@ pub fn main() anyerror!void { 10, 360, 10, - rl.Color.lime, + .lime, ); } // --------------------------------------------------------------------- diff --git a/examples/models/models_heightmap.zig b/examples/models/models_heightmap.zig index 425bf83..4b7fabc 100644 --- a/examples/models/models_heightmap.zig +++ b/examples/models/models_heightmap.zig @@ -28,16 +28,16 @@ pub fn main() anyerror!void { rl.setTargetFPS(60); while (!rl.windowShouldClose()) { - rl.updateCamera(&camera, rl.CameraMode.orbital); + rl.updateCamera(&camera, .orbital); rl.beginDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); rl.beginMode3D(camera); - rl.drawModel(model, mapPosition, 1, rl.Color.red); + rl.drawModel(model, mapPosition, 1, .red); rl.drawGrid(20, 1.0); rl.endMode3D(); - rl.drawTexture(texture, screenWidth - texture.width - 20, 20, rl.Color.white); - rl.drawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, rl.Color.green); + rl.drawTexture(texture, screenWidth - texture.width - 20, 20, .white); + rl.drawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, .green); rl.drawFPS(10, 10); rl.endDrawing(); diff --git a/examples/shaders/raymarching.zig b/examples/shaders/raymarching.zig index d97b6b8..432b35b 100644 --- a/examples/shaders/raymarching.zig +++ b/examples/shaders/raymarching.zig @@ -87,7 +87,7 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); // We only draw a white full-screen rectangle, // frame is generated in shader using raymarching @@ -100,7 +100,7 @@ pub fn main() anyerror!void { 0, rl.getScreenWidth(), rl.getScreenHeight(), - rl.Color.white, + .white, ); } @@ -109,7 +109,7 @@ pub fn main() anyerror!void { rl.getScreenWidth() - 280, rl.getScreenHeight() - 20, 10, - rl.Color.black, + .black, ); //---------------------------------------------------------------------------------- } diff --git a/examples/shaders/texture_outline.zig b/examples/shaders/texture_outline.zig index 502ea0d..bfcbde5 100644 --- a/examples/shaders/texture_outline.zig +++ b/examples/shaders/texture_outline.zig @@ -15,7 +15,7 @@ pub fn main() anyerror!void { rl.initWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture"); defer rl.closeWindow(); // Close window and OpenGL context - const texture: rl.Texture = try rl.Texture.init("resources/textures/fudesumi.png"); + const texture: rl.Texture = try .init("resources/textures/fudesumi.png"); defer rl.unloadTexture(texture); const shdrOutline: rl.Shader = try rl.loadShader(null, "resources/shaders/glsl330/outline.fs"); @@ -76,7 +76,7 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); { rl.beginShaderMode(shdrOutline); @@ -85,18 +85,18 @@ pub fn main() anyerror!void { texture.draw( @divFloor(rl.getScreenWidth(), 2) - @divFloor(texture.width, 2), -30, - rl.Color.white, + .white, ); } - rl.drawText("Shader-based\ntexture\noutline", 10, 10, 20, rl.Color.gray); + rl.drawText("Shader-based\ntexture\noutline", 10, 10, 20, .gray); rl.drawText( rl.textFormat("Outline size: %i px", .{@as(i32, @intFromFloat(outlineSize))}), 10, 120, 20, - rl.Color.maroon, + .maroon, ); rl.drawFPS(710, 10); diff --git a/examples/shapes/basic_shapes.zig b/examples/shapes/basic_shapes.zig index ab59d76..2686ebb 100644 --- a/examples/shapes/basic_shapes.zig +++ b/examples/shapes/basic_shapes.zig @@ -26,33 +26,33 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawText("some basic shapes available on raylib", 20, 20, 20, rl.Color.dark_gray); + rl.drawText("some basic shapes available on raylib", 20, 20, 20, .dark_gray); // Circle shapes and lines - rl.drawCircle(screenWidth / 5, 120, 35, rl.Color.dark_blue); - rl.drawCircleGradient(screenWidth / 5, 220, 60, rl.Color.green, rl.Color.sky_blue); - rl.drawCircleLines(screenWidth / 5, 340, 80, rl.Color.dark_blue); + rl.drawCircle(screenWidth / 5, 120, 35, .dark_blue); + rl.drawCircleGradient(screenWidth / 5, 220, 60, .green, .sky_blue); + rl.drawCircleLines(screenWidth / 5, 340, 80, .dark_blue); // Rectangle shapes and lines - rl.drawRectangle(screenWidth / 4 * 2 - 60, 100, 120, 60, rl.Color.red); - rl.drawRectangleGradientH(screenWidth / 4 * 2 - 90, 170, 180, 130, rl.Color.maroon, rl.Color.gold); - rl.drawRectangleLines(screenWidth / 4 * 2 - 40, 320, 80, 60, rl.Color.orange); // NOTE: Uses QUADS internally, not lines + rl.drawRectangle(screenWidth / 4 * 2 - 60, 100, 120, 60, .red); + rl.drawRectangleGradientH(screenWidth / 4 * 2 - 90, 170, 180, 130, .maroon, .gold); + rl.drawRectangleLines(screenWidth / 4 * 2 - 40, 320, 80, 60, .orange); // NOTE: Uses QUADS internally, not lines // Triangle shapes and lines - rl.drawTriangle((rl.Vector2){ .x = (screenWidth / 4.0 * 3.0), .y = 80.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 - 60.0), .y = 150.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 + 60.0), .y = 150.0 }, rl.Color.violet); + rl.drawTriangle(.{ .x = (screenWidth / 4.0 * 3.0), .y = 80.0 }, .{ .x = (screenWidth / 4.0 * 3.0 - 60.0), .y = 150.0 }, .{ .x = (screenWidth / 4.0 * 3.0 + 60.0), .y = 150.0 }, .violet); - rl.drawTriangleLines((rl.Vector2){ .x = (screenWidth / 4.0 * 3.0), .y = 160.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 - 20.0), .y = 230.0 }, (rl.Vector2){ .x = (screenWidth / 4.0 * 3.0 + 20.0), .y = 230.0 }, rl.Color.dark_blue); + rl.drawTriangleLines(.{ .x = (screenWidth / 4.0 * 3.0), .y = 160.0 }, .{ .x = (screenWidth / 4.0 * 3.0 - 20.0), .y = 230.0 }, .{ .x = (screenWidth / 4.0 * 3.0 + 20.0), .y = 230.0 }, .dark_blue); // Polygon shapes and lines - rl.drawPoly((rl.Vector2){ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 80, rotation, rl.Color.brown); - rl.drawPolyLines((rl.Vector2){ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 90, rotation, rl.Color.brown); - rl.drawPolyLinesEx((rl.Vector2){ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 85, rotation, 6, rl.Color.beige); + rl.drawPoly(.{ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 80, rotation, .brown); + rl.drawPolyLines(.{ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 90, rotation, .brown); + rl.drawPolyLinesEx(.{ .x = (screenWidth / 4.0 * 3), .y = 330 }, 6, 85, rotation, 6, .beige); // NOTE: We draw all LINES based shapes together to optimize internal drawing, // this way, all LINES are rendered in a single draw pass - rl.drawLine(18, 42, screenWidth - 18, 42, rl.Color.black); + rl.drawLine(18, 42, screenWidth - 18, 42, .black); //---------------------------------------------------------------------------------- } } diff --git a/examples/shapes/bouncing_ball.zig b/examples/shapes/bouncing_ball.zig index 87399a2..8347755 100644 --- a/examples/shapes/bouncing_ball.zig +++ b/examples/shapes/bouncing_ball.zig @@ -53,14 +53,14 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawCircleV(ballPosition, ballRadius, rl.Color.maroon); - rl.drawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, rl.getScreenHeight() - 25, 20, rl.Color.light_gray); + rl.drawCircleV(ballPosition, ballRadius, .maroon); + rl.drawText("PRESS SPACE to PAUSE BALL MOVEMENT", 10, rl.getScreenHeight() - 25, 20, .light_gray); // On pause, we draw a blinking message if (pause and @mod(@divFloor(framesCounter, 30), 2) == 0) { - rl.drawText("PAUSED", 350, 200, 30, rl.Color.gray); + rl.drawText("PAUSED", 350, 200, 30, .gray); } rl.drawFPS(10, 10); diff --git a/examples/shapes/collision_area.zig b/examples/shapes/collision_area.zig index 321c291..cf05c51 100644 --- a/examples/shapes/collision_area.zig +++ b/examples/shapes/collision_area.zig @@ -1,8 +1,8 @@ const rl = @import("raylib"); fn boxFmt(colliding: bool) rl.Color { - if (colliding) return rl.Color.red; - return rl.Color.black; + if (colliding) return .red; + return .black; } pub fn main() anyerror!void { @@ -83,12 +83,12 @@ pub fn main() anyerror!void { rl.drawRectangle(0, 0, screenWidth, screenUpperLimit, boxFmt(collision)); - rl.drawRectangleRec(boxA, rl.Color.gold); - rl.drawRectangleRec(boxB, rl.Color.blue); + rl.drawRectangleRec(boxA, .gold); + rl.drawRectangleRec(boxB, .blue); if (collision) { // Draw collision area - rl.drawRectangleRec(boxCollision, rl.Color.lime); + rl.drawRectangleRec(boxCollision, .lime); // Draw collision message rl.drawText( @@ -96,19 +96,19 @@ pub fn main() anyerror!void { @divFloor(rl.getScreenWidth(), @as(i32, 2)) - @divFloor(rl.measureText("COLLISION!", 20), @as(i32, 2)), screenUpperLimit / 2 - 10, 20, - rl.Color.black, + .black, ); // Draw collision area - rl.drawText(rl.textFormat("Collision Area: %i", .{@as(i32, @intFromFloat(boxCollision.width * boxCollision.height))}), @divFloor(rl.getScreenWidth(), 2) - 100, screenUpperLimit + 10, 20, rl.Color.black); + rl.drawText(rl.textFormat("Collision Area: %i", .{@as(i32, @intFromFloat(boxCollision.width * boxCollision.height))}), @divFloor(rl.getScreenWidth(), 2) - 100, screenUpperLimit + 10, 20, .black); } // Draw help instructions - rl.drawText("Press SPACE to PAUSE/RESUME", 20, screenHeight - 35, 20, rl.Color.light_gray); + rl.drawText("Press SPACE to PAUSE/RESUME", 20, screenHeight - 35, 20, .light_gray); rl.drawFPS(10, 10); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); //---------------------------------------------------------------------------------- } } diff --git a/examples/shapes/colors_palette.zig b/examples/shapes/colors_palette.zig index 09763a3..ca8636f 100644 --- a/examples/shapes/colors_palette.zig +++ b/examples/shapes/colors_palette.zig @@ -20,27 +20,27 @@ pub fn main() anyerror!void { defer rl.closeWindow(); // Close window and OpenGL context const colors = [maxColorCount]rl.Color{ - rl.Color.dark_gray, - rl.Color.maroon, - rl.Color.orange, - rl.Color.dark_green, - rl.Color.dark_blue, - rl.Color.dark_purple, - rl.Color.dark_brown, - rl.Color.gray, - rl.Color.red, - rl.Color.gold, - rl.Color.lime, - rl.Color.blue, - rl.Color.violet, - rl.Color.brown, - rl.Color.light_gray, - rl.Color.pink, - rl.Color.yellow, - rl.Color.green, - rl.Color.sky_blue, - rl.Color.purple, - rl.Color.beige, + .dark_gray, + .maroon, + .orange, + .dark_green, + .dark_blue, + .dark_purple, + .dark_brown, + .gray, + .red, + .gold, + .lime, + .blue, + .violet, + .brown, + .light_gray, + .pink, + .yellow, + .green, + .sky_blue, + .purple, + .beige, }; const colorNames = [maxColorCount][:0]const u8{ @@ -105,18 +105,18 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawText("raylib colors palette", 28, 42, 20, rl.Color.black); - rl.drawText("press SPACE to see all colors", rl.getScreenWidth() - 180, rl.getScreenHeight() - 40, 10, rl.Color.gray); + rl.drawText("raylib colors palette", 28, 42, 20, .black); + rl.drawText("press SPACE to see all colors", rl.getScreenWidth() - 180, rl.getScreenHeight() - 40, 10, .gray); i = 0; while (i < maxColorCount) : (i += 1) { - rl.drawRectangleRec(colorsRecs[i], rl.fade(colors[i], getAlpha(colorState[i]))); + rl.drawRectangleRec(colorsRecs[i], .fade(colors[i], getAlpha(colorState[i]))); if (rl.isKeyDown(.space) or colorState[i]) { - rl.drawRectangle(@intFromFloat(colorsRecs[i].x), @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 26, @as(i32, @intFromFloat(colorsRecs[i].width)), 20, rl.Color.black); - rl.drawRectangleLinesEx(colorsRecs[i], 6, rl.fade(rl.Color.black, 0.3)); + rl.drawRectangle(@intFromFloat(colorsRecs[i].x), @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 26, @as(i32, @intFromFloat(colorsRecs[i].width)), 20, .black); + rl.drawRectangleLinesEx(colorsRecs[i], 6, .fade(.black, 0.3)); rl.drawText(colorNames[i], @as(i32, @intFromFloat(colorsRecs[i].x)) + @as(i32, @intFromFloat(colorsRecs[i].width)) - rl.measureText(colorNames[i], 10) - 12, @as(i32, @intFromFloat(colorsRecs[i].y)) + @as(i32, @intFromFloat(colorsRecs[i].height)) - 20, 10, colors[i]); } diff --git a/examples/shapes/draw_circle_sector.zig b/examples/shapes/draw_circle_sector.zig index b635a8e..99ad707 100644 --- a/examples/shapes/draw_circle_sector.zig +++ b/examples/shapes/draw_circle_sector.zig @@ -9,8 +9,8 @@ fn labelFmt(segments: f32, minSegments: f32) [*c]const u8 { } fn colorFmt(segments: f32, minSegments: f32) rl.Color { - if (segments >= minSegments) return rl.Color.maroon; - return rl.Color.dark_gray; + if (segments >= minSegments) return .maroon; + return .dark_gray; } pub fn main() anyerror!void { @@ -45,13 +45,13 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawLine(500, 0, 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.6)); - rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.3)); + rl.drawLine(500, 0, 500, rl.getScreenHeight(), .fade(.light_gray, 0.6)); + rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), .fade(.light_gray, 0.3)); - rl.drawCircleSector(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), rl.fade(rl.Color.maroon, 0.3)); - rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), rl.fade(rl.Color.maroon, 0.6)); + rl.drawCircleSector(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), .fade(.maroon, 0.3)); + rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @as(i32, @intFromFloat(segments)), .fade(.maroon, 0.6)); // Draw GUI controls _ = rgui.guiSliderBar(rl.Rectangle{ .x = 600, .y = 40, .width = 120, .height = 20 }, "StartAngle", rl.textFormat("%.2", .{startAngle}), &startAngle, 0, 720); diff --git a/examples/shapes/draw_rectangle_rounded.zig b/examples/shapes/draw_rectangle_rounded.zig index d7c3f34..9fd1a3f 100644 --- a/examples/shapes/draw_rectangle_rounded.zig +++ b/examples/shapes/draw_rectangle_rounded.zig @@ -7,8 +7,8 @@ fn labelFmt(segments: f32) [*c]const u8 { } fn colorFmt(segments: f32) rl.Color { - if (segments >= 4) return rl.Color.maroon; - return rl.Color.dark_gray; + if (segments >= 4) return .maroon; + return .dark_gray; } pub fn main() anyerror!void { @@ -45,14 +45,14 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawLine(560, 0, 560, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.6)); - rl.drawRectangle(560, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.3)); + rl.drawLine(560, 0, 560, rl.getScreenHeight(), .fade(.light_gray, 0.6)); + rl.drawRectangle(560, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), .fade(.light_gray, 0.3)); - if (drawRect) rl.drawRectangleRec(rec, rl.fade(rl.Color.gold, 0.6)); - if (drawRoundedRect) rl.drawRectangleRounded(rec, roundness, @as(i32, @intFromFloat(segments)), rl.fade(rl.Color.maroon, 0.2)); - if (drawRoundedLines) rl.drawRectangleRoundedLinesEx(rec, roundness, @as(i32, @intFromFloat(segments)), lineThick, rl.fade(rl.Color.maroon, 0.4)); + if (drawRect) rl.drawRectangleRec(rec, .fade(.gold, 0.6)); + if (drawRoundedRect) rl.drawRectangleRounded(rec, roundness, @as(i32, @intFromFloat(segments)), .fade(.maroon, 0.2)); + if (drawRoundedLines) rl.drawRectangleRoundedLinesEx(rec, roundness, @as(i32, @intFromFloat(segments)), lineThick, .fade(.maroon, 0.4)); // Draw GUI controls _ = rgui.guiSliderBar(rl.Rectangle{ .x = 640, .y = 40, .width = 105, .height = 20 }, "Width", rl.textFormat("%.2", .{width}), &width, 0, @as(f32, @floatFromInt(rl.getScreenWidth() - 300))); diff --git a/examples/shapes/draw_ring.zig b/examples/shapes/draw_ring.zig index 378eaed..27f374b 100644 --- a/examples/shapes/draw_ring.zig +++ b/examples/shapes/draw_ring.zig @@ -9,8 +9,8 @@ fn labelFmt(segments: f32, minSegments: f32) [*c]const u8 { } fn colorFmt(segments: f32, minSegments: f32) rl.Color { - if (segments >= minSegments) return rl.Color.maroon; - return rl.Color.dark_gray; + if (segments >= minSegments) return .maroon; + return .dark_gray; } pub fn main() anyerror!void { @@ -50,14 +50,14 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawLine(500, 0, 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.6)); - rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), rl.fade(rl.Color.light_gray, 0.3)); + rl.drawLine(500, 0, 500, rl.getScreenHeight(), .fade(.light_gray, 0.6)); + rl.drawRectangle(500, 0, rl.getScreenWidth() - 500, rl.getScreenHeight(), .fade(.light_gray, 0.3)); - if (drawRing) rl.drawRing(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), rl.fade(rl.Color.maroon, 0.3)); - if (drawRingLines) rl.drawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), rl.fade(rl.Color.black, 0.4)); - if (drawCircleLines) rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @intFromFloat(segments), rl.fade(rl.Color.black, 0.4)); + if (drawRing) rl.drawRing(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), .fade(.maroon, 0.3)); + if (drawRingLines) rl.drawRingLines(center, innerRadius, outerRadius, startAngle, endAngle, @intFromFloat(segments), .fade(.black, 0.4)); + if (drawCircleLines) rl.drawCircleSectorLines(center, outerRadius, startAngle, endAngle, @intFromFloat(segments), .fade(.black, 0.4)); // Draw GUI controls //------------------------------------------------------------------------------ diff --git a/examples/shapes/following_eyes.zig b/examples/shapes/following_eyes.zig index 4ea1216..6cbb716 100644 --- a/examples/shapes/following_eyes.zig +++ b/examples/shapes/following_eyes.zig @@ -69,17 +69,17 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.drawCircleV(scleraLeftPosition, scleraRadius, rl.Color.light_gray); - rl.drawCircleV(irisLeftPosition, irisRadius, rl.Color.brown); - rl.drawCircleV(irisLeftPosition, 10, rl.Color.black); + rl.drawCircleV(scleraLeftPosition, scleraRadius, .light_gray); + rl.drawCircleV(irisLeftPosition, irisRadius, .brown); + rl.drawCircleV(irisLeftPosition, 10, .black); - rl.drawCircleV(scleraRightPosition, scleraRadius, rl.Color.light_gray); - rl.drawCircleV(irisRightPosition, irisRadius, rl.Color.dark_green); - rl.drawCircleV(irisRightPosition, 10, rl.Color.black); + rl.drawCircleV(scleraRightPosition, scleraRadius, .light_gray); + rl.drawCircleV(irisRightPosition, irisRadius, .dark_green); + rl.drawCircleV(irisRightPosition, 10, .black); rl.drawFPS(10, 10); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); //---------------------------------------------------------------------------------- } } diff --git a/examples/shapes/lines_bezier.zig b/examples/shapes/lines_bezier.zig index 4cb1d0f..f30e8e2 100644 --- a/examples/shapes/lines_bezier.zig +++ b/examples/shapes/lines_bezier.zig @@ -6,8 +6,8 @@ fn collisionFmt(isColliding: bool) f32 { } fn movingFmt(isMoving: bool) rl.Color { - if (isMoving) return rl.Color.red; - return rl.Color.blue; + if (isMoving) return .red; + return .blue; } pub fn main() anyerror!void { @@ -60,12 +60,12 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawText("MOVE START-END POINTS WITH MOUSE", 15, 20, 20, rl.Color.gray); + rl.drawText("MOVE START-END POINTS WITH MOUSE", 15, 20, 20, .gray); // Draw line Cubic Bezier, in-out interpolation (easing), no control points - rl.drawLineBezier(startPoint, endPoint, 4.0, rl.Color.blue); + rl.drawLineBezier(startPoint, endPoint, 4.0, .blue); // Draw start-end spline circles with some details rl.drawCircleV(startPoint, collisionFmt(rl.checkCollisionPointCircle(mouse, startPoint, 10.0)), movingFmt(moveStartPoint)); diff --git a/examples/shapes/logo_raylib.zig b/examples/shapes/logo_raylib.zig index 3c5e300..7721f0c 100644 --- a/examples/shapes/logo_raylib.zig +++ b/examples/shapes/logo_raylib.zig @@ -28,13 +28,13 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); rl.drawRectangle(screenWidth / 2 - 128, screenHeight / 2 - 128, 256, 256, raylib_zig); - rl.drawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, rl.Color.ray_white); + rl.drawRectangle(screenWidth / 2 - 112, screenHeight / 2 - 112, 224, 224, .ray_white); rl.drawText("raylib-zig", screenWidth / 2 - 96, screenHeight / 2 + 57, 41, raylib_zig); - rl.drawText("this is NOT a texture!", 350, 370, 10, rl.Color.gray); + rl.drawText("this is NOT a texture!", 350, 370, 10, .gray); //---------------------------------------------------------------------------------- } } diff --git a/examples/shapes/logo_raylib_anim.zig b/examples/shapes/logo_raylib_anim.zig index 586490c..330286d 100644 --- a/examples/shapes/logo_raylib_anim.zig +++ b/examples/shapes/logo_raylib_anim.zig @@ -90,37 +90,37 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); if (state == 0) { - if (@mod(framesCounter, @as(u8, 15)) == 0) rl.drawRectangle(logoPositionX, logoPositionY, 16, 16, rl.Color.black); + if (@mod(framesCounter, @as(u8, 15)) == 0) rl.drawRectangle(logoPositionX, logoPositionY, 16, 16, .black); } else if (state == 1) { - rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, rl.Color.black); - rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, rl.Color.black); + rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, .black); + rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, .black); } else if (state == 2) { - rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, rl.Color.black); - rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, rl.Color.black); + rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, .black); + rl.drawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, .black); - rl.drawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, rl.Color.black); - rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, rl.Color.black); + rl.drawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, .black); + rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, .black); } else if (state == 3) { - rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, rl.fade(rl.Color.black, alpha)); - rl.drawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, rl.fade(rl.Color.black, alpha)); + rl.drawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, .fade(.black, alpha)); + rl.drawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, .fade(.black, alpha)); - rl.drawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, rl.fade(rl.Color.black, alpha)); - rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, rl.fade(rl.Color.black, alpha)); + rl.drawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, .fade(.black, alpha)); + rl.drawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, .fade(.black, alpha)); rl.drawRectangle( (@divFloor(rl.getScreenWidth(), @as(i32, 2))) - 112, (@divFloor(rl.getScreenHeight(), @as(i32, 2))) - 112, 224, 224, - rl.fade(rl.Color.ray_white, alpha), + .fade(.ray_white, alpha), ); - rl.drawText(rl.textSubtext("raylib", 0, lettersCount), @divFloor(rl.getScreenWidth(), @as(i32, 2)) - 44, @divFloor(rl.getScreenHeight(), @as(i32, 2)) + 48, 50, rl.fade(rl.Color.black, alpha)); + rl.drawText(rl.textSubtext("raylib", 0, lettersCount), @divFloor(rl.getScreenWidth(), @as(i32, 2)) - 44, @divFloor(rl.getScreenHeight(), @as(i32, 2)) + 48, 50, .fade(.black, alpha)); } else if (state == 4) { - rl.drawText("[R] REPLAY", 340, 200, 20, rl.Color.gray); + rl.drawText("[R] REPLAY", 340, 200, 20, .gray); } //---------------------------------------------------------------------------------- diff --git a/examples/shapes/rectangle_scaling.zig b/examples/shapes/rectangle_scaling.zig index e67c51f..3bcffd0 100644 --- a/examples/shapes/rectangle_scaling.zig +++ b/examples/shapes/rectangle_scaling.zig @@ -68,15 +68,15 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, rl.Color.gray); + rl.drawText("Scale rectangle dragging from bottom-right corner!", 10, 10, 20, .gray); - rl.drawRectangleRec(rec, rl.fade(rl.Color.green, 0.5)); + rl.drawRectangleRec(rec, .fade(.green, 0.5)); if (mouseScaleReady) { - rl.drawRectangleLinesEx(rec, 1, rl.Color.red); - rl.drawTriangle(rl.Vector2{ .x = rec.x + rec.width - mouseScaleMarkSize, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height - mouseScaleMarkSize }, rl.Color.red); + rl.drawRectangleLinesEx(rec, 1, .red); + rl.drawTriangle(rl.Vector2{ .x = rec.x + rec.width - mouseScaleMarkSize, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height }, rl.Vector2{ .x = rec.x + rec.width, .y = rec.y + rec.height - mouseScaleMarkSize }, .red); } //---------------------------------------------------------------------------------- } diff --git a/examples/text/text_format_text.zig b/examples/text/text_format_text.zig index 5ea8c40..e05bce4 100644 --- a/examples/text/text_format_text.zig +++ b/examples/text/text_format_text.zig @@ -35,15 +35,15 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.white); + rl.clearBackground(.white); - rl.drawText(rl.textFormat("Score: %08i", .{score}), 200, 80, 20, rl.Color.red); + rl.drawText(rl.textFormat("Score: %08i", .{score}), 200, 80, 20, .red); - rl.drawText(rl.textFormat("HiScore: %08i", .{hiscore}), 200, 120, 20, rl.Color.green); + rl.drawText(rl.textFormat("HiScore: %08i", .{hiscore}), 200, 120, 20, .green); - rl.drawText(rl.textFormat("Lives: %02i", .{lives}), 200, 160, 40, rl.Color.blue); + rl.drawText(rl.textFormat("Lives: %02i", .{lives}), 200, 160, 40, .blue); - rl.drawText(rl.textFormat("Elapsed Time: %02.02f ms", .{rl.getFrameTime() * 1000}), 200, 220, 20, rl.Color.black); + rl.drawText(rl.textFormat("Elapsed Time: %02.02f ms", .{rl.getFrameTime() * 1000}), 200, 220, 20, .black); //---------------------------------------------------------------------------------- } } diff --git a/examples/text/text_writing_anim.zig b/examples/text/text_writing_anim.zig index 941ee71..859c82e 100644 --- a/examples/text/text_writing_anim.zig +++ b/examples/text/text_writing_anim.zig @@ -25,9 +25,9 @@ pub fn main() void { { // Update //---------------------------------------------------------------------------------- - framesCounter += if (rl.isKeyDown(rl.KeyboardKey.space)) 8 else 1; + framesCounter += if (rl.isKeyDown(.space)) 8 else 1; - if (rl.isKeyPressed(rl.KeyboardKey.enter)) framesCounter = 0; + if (rl.isKeyPressed(.enter)) framesCounter = 0; //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- diff --git a/examples/textures/sprite_anim.zig b/examples/textures/sprite_anim.zig index ae60af6..05801ad 100644 --- a/examples/textures/sprite_anim.zig +++ b/examples/textures/sprite_anim.zig @@ -17,7 +17,7 @@ pub fn main() anyerror!void { defer rl.closeWindow(); // Close window and OpenGL context // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - const scarfy: rl.Texture = try rl.Texture.init("resources/textures/scarfy.png"); // Texture loading + const scarfy = try rl.Texture.init("resources/textures/scarfy.png"); // Texture loading defer rl.unloadTexture(scarfy); // Texture unloading const position = rl.Vector2.init(350.0, 280.0); @@ -70,37 +70,37 @@ pub fn main() anyerror!void { rl.beginDrawing(); defer rl.endDrawing(); - rl.clearBackground(rl.Color.ray_white); + rl.clearBackground(.ray_white); - rl.drawTexture(scarfy, 15, 40, rl.Color.white); - rl.drawRectangleLines(15, 40, scarfy.width, scarfy.height, rl.Color.lime); + rl.drawTexture(scarfy, 15, 40, .white); + rl.drawRectangleLines(15, 40, scarfy.width, scarfy.height, .lime); rl.drawRectangleLines( 15 + @as(i32, @intFromFloat(frameRec.x)), 40 + @as(i32, @intFromFloat(frameRec.y)), @as(i32, @intFromFloat(frameRec.width)), @as(i32, @intFromFloat(frameRec.height)), - rl.Color.red, + .red, ); - rl.drawText("FRAME SPEED: ", 165, 210, 10, rl.Color.dark_gray); - rl.drawText(rl.textFormat("%02i FPS", .{framesSpeed}), 575, 210, 10, rl.Color.dark_gray); - rl.drawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, rl.Color.dark_gray); + rl.drawText("FRAME SPEED: ", 165, 210, 10, .dark_gray); + rl.drawText(rl.textFormat("%02i FPS", .{framesSpeed}), 575, 210, 10, .dark_gray); + rl.drawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, .dark_gray); for ([_]u32{0} ** MAX_FRAME_SPEED, 0..) |_, i| { if (i < framesSpeed) { - rl.drawRectangle(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, rl.Color.red); + rl.drawRectangle(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, .red); } - rl.drawRectangleLines(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, rl.Color.maroon); + rl.drawRectangleLines(250 + 21 * @as(i32, @intCast(i)), 205, 20, 20, .maroon); } - scarfy.drawRec(frameRec, position, rl.Color.white); // Draw part of the texture + scarfy.drawRec(frameRec, position, .white); // Draw part of the texture rl.drawText( "(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, - rl.Color.gray, + .gray, ); //---------------------------------------------------------------------------------- } diff --git a/examples/textures/textures_background_scrolling.zig b/examples/textures/textures_background_scrolling.zig index d46c1e0..1cabebe 100644 --- a/examples/textures/textures_background_scrolling.zig +++ b/examples/textures/textures_background_scrolling.zig @@ -59,49 +59,49 @@ pub fn main() anyerror!void { // NOTE: Texture is scaled twice its size rl.drawTextureEx( background, - rl.Vector2.init(scrolling_back, 20.0), + .init(scrolling_back, 20.0), 0.0, 2.0, - rl.Color.white, + .white, ); rl.drawTextureEx( background, - rl.Vector2.init(@as(f32, @floatFromInt(background.width * 2)) + scrolling_back, 20), + .init(@as(f32, @floatFromInt(background.width * 2)) + scrolling_back, 20), 0.0, 2.0, - rl.Color.white, + .white, ); // Draw midground image twice rl.drawTextureEx( midground, - rl.Vector2.init(scrolling_mid, 20.0), + .init(scrolling_mid, 20.0), 0.0, 2.0, - rl.Color.white, + .white, ); rl.drawTextureEx( midground, - rl.Vector2.init(@as(f32, @floatFromInt(midground.width * 2)) + scrolling_mid, 20), + .init(@as(f32, @floatFromInt(midground.width * 2)) + scrolling_mid, 20), 0.0, 2.0, - rl.Color.white, + .white, ); // Draw foreground image twice rl.drawTextureEx( foreground, - rl.Vector2.init(scrolling_fore, 70.0), + .init(scrolling_fore, 70.0), 0.0, 2.0, - rl.Color.white, + .white, ); rl.drawTextureEx( foreground, - rl.Vector2.init(@as(f32, @floatFromInt(foreground.width * 2)) + scrolling_fore, 70), + .init(@as(f32, @floatFromInt(foreground.width * 2)) + scrolling_fore, 70), 0.0, 2.0, - rl.Color.white, + .white, ); rl.drawText( @@ -109,14 +109,14 @@ pub fn main() anyerror!void { 10, 10, 20, - rl.Color.red, + .red, ); rl.drawText( "(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", screen_width - 330, screen_height - 20, 10, - rl.Color.ray_white, + .ray_white, ); } }