Example #1
0
 public function render(Scene $scene, Image $image, $w, $h)
 {
     $camera = $scene->camera();
     $camPos = $camera->pos;
     for ($y = 0; $y < $h; ++$y) {
         for ($x = 0; $x < $w; ++$x) {
             $ray = new Ray($camPos, self::getPoint($x, $y, $camera, $w, $h));
             $color = Color::toDrawingColor($this->traceRay($ray, $scene, 0));
             $image->setPixel($x, $y, $color);
         }
     }
 }