From 0c97c2124e83b0bcf8719a62ce3704602ee66c38 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Tue, 17 Dec 2024 20:56:01 +0100 Subject: ppm: simple example to generate a ppm image --- ppm/main.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ppm/main.zig (limited to 'ppm/main.zig') diff --git a/ppm/main.zig b/ppm/main.zig new file mode 100644 index 0000000..6e1bb1b --- /dev/null +++ b/ppm/main.zig @@ -0,0 +1,22 @@ +const std = @import("std"); +const ppm = @import("ppm.zig"); + +pub fn main() !void { + var img = ppm.ppm(200, 200).init; + defer img.dump("test.ppm") catch unreachable; + + for (img.row(10)) |*px| { + px.*.r = 255; + } + for (img.row(20)) |*px| { + px.*.g = 255; + } + for (img.row(30)) |*px| { + px.*.b = 255; + } + + const white = ppm.Pixel{ .r = 255, .g = 255, .b = 255 }; + + img.set(100, 100, white); + img.set(199, 199, white); +} -- cgit v1.2.3