diff -r fcf1487b398b -r f6a72eb99631 demos/spheres_shadow.py --- a/demos/spheres_shadow.py Tue Apr 29 13:56:29 2008 +0200 +++ b/demos/spheres_shadow.py Tue Apr 29 23:31:08 2008 +0200 @@ -1,9 +1,11 @@ #!/usr/bin/python -from raytracer import Raytracer, Material, Box, Sphere, Light -import Image +from pyrit import * rt = Raytracer() +top = KdTree() +rt.setTop(top) +rt.setCamera(Camera()) light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) rt.addLight(light1) @@ -28,7 +30,9 @@ tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3) rt.addShape(tinysphere) -imagesize = (800, 600) -data = rt.render(imagesize) -img = Image.fromstring("RGB", imagesize, data) -img.save('spheres_shadow.png') +top.optimize() + +sampler = DefaultSampler(800, 600) +rt.setSampler(sampler) +rt.render() +sampler.getPixmap().writePNG('spheres_shadow.png')