r/tinycode • • Jan 09 '13

Ray tracer in 140 SLOC of python with picture

I have be playing with raytracing for a while now and wanted to write something that was simple to understand but produced a cool effect. There is defiantly many more features that could be added, like reflections and multiple light sources, but I wanted to stay as minimalistic possible.

Source: http://pastebin.com/F8f5GHJZ

Image: http://imgur.com/prPGk

70 Upvotes

35 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Jan 10 '13

Weird, IO is super costly on my machine.

1

u/theinternetftw Jan 10 '13

Depends on your terminal, I think. If you're printing to it faster than it can keep up, that's when things start to chug. I've seen the terminal's CPU usage spike as an indicator for when that happens. In this case (at least for me), by the time another number's being printed the terminal's had time to finish the earlier one.