class RayTracerMain(object): def __init__(self, scene, screen_width=100, screen_height=100): self.scene = scene self.ray_generator = RayGenerator( self.scene.direction, screen_width, screen_height ) self.ray_tracer = RayTracer(scene) self.screen = Screen(screen_width, screen_height) def trace_scene(self): for (x, y), ray in self.ray_generator.yield_primary_rays(): # TODO: create a ray class to encapsulate ray + position so this # class doesn't have to know about the scene pixel_color = self.ray_tracer.find_pixel_color_for_ray( ray, self.scene.position ) self.screen.write_pixel(x, y, pixel_color) def export_png(self, filename): self.screen.dump_to_png(filename)