21 lines
527 B
Python
Executable file
21 lines
527 B
Python
Executable file
#!python
|
|
from PIL import Image
|
|
from mechthild import Scene, Shape, Camera
|
|
|
|
WIDTH = 800
|
|
HEIGHT = 600
|
|
SAMPLES = 32
|
|
|
|
s1 = Shape.sphere((0.75, 1.0, 1.0), 1.0)
|
|
s2 = Shape.sphere((-1.5, 2.0, -2.0), 2.0)
|
|
ground = Shape.plane((0.0, 1.0, 0.0), 0.0)
|
|
|
|
camera = Camera((0.0, 1.5, 5.0), (0.0, 1.0, 0.0), (0.0, 1.0, 0.0), 80.0)
|
|
|
|
scene = Scene(camera, [s1, s2, ground])
|
|
|
|
render = scene.render(WIDTH, HEIGHT, SAMPLES)
|
|
rgba = bytes([int(v * 255) for v in render])
|
|
|
|
image = Image.frombuffer('RGBA', (WIDTH, HEIGHT), rgba)
|
|
image.save("test.png")
|