print(spam) lookfrom: Vec3 = Vec3(9, -2, -1) lookat: Vec3 = Vec3(-4, 1, 0) focus_distance: float = 10.0 aperture: float = 0.1 camera: Camera = PositionableCamera(lookfrom, lookat, Vec3(0, 1, 0), 20, width / height, aperture, focus_distance) for j in range(height - 1, -1, -1): for i in range(width): #print("Tracing on row %s, col %s" % (j, i)) accumulator: Vec3 = Vec3(0, 0, 0) for sample in range(sampling_size): u: float = i + random.random() / width v: float = j + random.random() / height r: Ray = camera.get_ray(u, v) accumulator += color(r, world, 0) accumulator /= sampling_size accumulator.map(math.sqrt) accumulator *= 255.9 accumulator.map(int) ppm.set_pixel((height - 1) - j, i, accumulator) ppm.write(_derive_ppm_filename())
from src.ppm import PPM from src.utils import _derive_ppm_filename from src.vec3 import Vec3 if __name__ == "__main__": hello_world = PPM(300, 200) for ri in range(hello_world.height): for ci in range(hello_world.width): v = Vec3(ri / hello_world.width, ci / hello_world.height, 0.2) color = v * 255.99 color.map(int) hello_world.set_pixel(ri, ci, color) hello_world.write(_derive_ppm_filename())