about summary refs log tree commit diff
path: root/src/main.zig
diff options
context:
space:
mode:
authoriurii plugatarov <[email protected]>2024-08-04 13:25:24 +0200
committeriurii plugatarov <[email protected]>2024-08-04 13:25:24 +0200
commit0b93bb6376e71b5edd336e179de04f0278322a80 (patch)
tree002935a36d693d80f12d3f69744309360111a516 /src/main.zig
parent67e09cb56ed03efeaf0b7899b0de9844f46f9e92 (diff)
downloaddsazitty-main.tar.gz
some visualization main
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 13ab026..5a26b41 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,3 +1,46 @@
 const std = @import("std");
+const c = @import("c.zig");
 
-pub fn main() !void {}
+pub fn main() !void {
+    const width = 800;
+    const height = 600;
+    c.InitWindow(width, height, "dsa viz");
+    c.SetTargetFPS(60);
+
+    const original: [6]i32 = .{ 10, 3, 4, 1, 50, 30 };
+    var input_array: [6]i32 = original;
+    var i: usize = 0;
+    var j: usize = 0;
+
+    while (!c.WindowShouldClose()) {
+        c.ClearBackground(c.BLACK);
+
+        c.BeginDrawing();
+        var x_pos: i32 = width / 2;
+        for (input_array) |e| {
+            c.DrawRectangle(x_pos, height - (height / 2) - (e * 5), 20, e * 5, c.RED);
+            x_pos += 30;
+        }
+
+        if (j < input_array.len - 1 - i) {
+            if (input_array[j] > input_array[j + 1]) {
+                const temp = input_array[j];
+                input_array[j] = input_array[j + 1];
+                input_array[j + 1] = temp;
+            }
+            j += 1;
+        } else {
+            i += 1;
+            j = 0;
+
+            if (i >= input_array.len - 1) {
+                input_array = original;
+                i = 0;
+                j = 0;
+            }
+        }
+        c.WaitTime(0.5);
+
+        c.EndDrawing();
+    }
+}