From 7c97adabbea2bd5f9fe66bdfda01cf699830f69f Mon Sep 17 00:00:00 2001 From: nothke Date: Wed, 12 Jun 2024 01:26:06 +0200 Subject: [PATCH] Colorful circle --- src/main.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 20e9807..fde474b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -25,7 +25,7 @@ export fn init() void { std.log.info("Vertex buffers len: {}", .{state.bind.vertex_buffers.len}); const vertexCount = 8; - const radius: f32 = 0.4; + const radius: f32 = 0.7; const cX: f32 = 0; const cY: f32 = 0; @@ -36,6 +36,9 @@ export fn init() void { const angleDiff: f32 = 1 / @as(f32, @floatFromInt(vertexCount)); + var pcg = std.Random.Pcg.init(123); + const rand = pcg.random(); + for (0..vertexCount) |i| { const pi: f32 = @floatCast(std.math.pi); const angle: f32 = @as(f32, @floatFromInt(i)) * angleDiff * pi * 2; @@ -47,6 +50,11 @@ export fn init() void { triangleVerts[si + 0] = x; triangleVerts[si + 1] = y; triangleVerts[si + 2] = 0.5; + + triangleVerts[si + 3] = rand.float(f32); + triangleVerts[si + 4] = rand.float(f32); + triangleVerts[si + 5] = rand.float(f32); + triangleVerts[si + 6] = 1; } // var triangleVerts = [_]f32{