blob: 9983774438fe0aaa9a71114f2fca4c9404276820 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
const std = @import("std");
pub fn main() !void {
const width = 256;
const height = 256;
std.debug.print("P3\n{} {}\n255\n", .{ width, height });
var j: usize = height;
while (j > 0) : (j -= 1) {
var i: usize = 0;
while (i < width) : (i += 1) {
var r: f32 = @intToFloat(f32, i) / (width - 1);
var g: f32 = @intToFloat(f32, j) / (height - 1);
var b: f32 = 0.25;
var ir: usize = @floatToInt(usize, r * 255.999);
var ig: usize = @floatToInt(usize, g * 255.999);
var ib: usize = @floatToInt(usize, b * 255.999);
std.debug.print("{} {} {}\n", .{ ir, ig, ib });
}
}
}
|