diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-12-16 16:48:55 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-12-16 16:58:58 -0500 |
commit | bc5457ce38af0543b971884cf11824c3fdc34248 (patch) | |
tree | 4c931b5a3f8d46f653d81133b94c193a760d100e /dimension/tests/cube.dmnsn | |
parent | 6b94e0329841ed8e80dbb55a3f8c2eee41b3168b (diff) | |
download | dimension-bc5457ce38af0543b971884cf11824c3fdc34248.tar.xz |
Use inheritance for spheres in cube test.
Diffstat (limited to 'dimension/tests/cube.dmnsn')
-rw-r--r-- | dimension/tests/cube.dmnsn | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/dimension/tests/cube.dmnsn b/dimension/tests/cube.dmnsn index 22c926d..5f74219 100644 --- a/dimension/tests/cube.dmnsn +++ b/dimension/tests/cube.dmnsn @@ -17,8 +17,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### -camera = PerspectiveCamera(location = (3, 6, -11), - look_at = 0) +camera = PerspectiveCamera( + location = (3, 6, -11), + look_at = 0, +) background = 0.5*sRGB(0.73, 0.90, 0.97) @@ -40,30 +42,32 @@ objects.append( ) ) -def make_sphere(x, y, z, size): - size -= 1 +class ShinySphere(Sphere): + def __init__(self, x, y, z, size): + size -= 1 - dx = sin(2*pi*x/size) - dy = sin(2*pi*y/size) - dz = sin(2*pi*z/size) - return Sphere( - center = 5*Vector(x, y, z)/size - + Vector(dy + dz, dx + dz, dx + dy)/4 - - Vector(2.5, 2.5, 2.5), - radius = 2/size, + dx = sin(2*pi*x/size) + dy = sin(2*pi*y/size) + dz = sin(2*pi*z/size) + Sphere.__init__( + self, + center = 5*Vector(x, y, z)/size + + Vector(dy + dz, dx + dz, dx + dy)/4 + - Vector(2.5, 2.5, 2.5), + radius = 2/size, - texture = Texture( - pigment = sRGB(x/size, y/size, z/size), - finish = Ambient(sRGB(0.25)) - + Diffuse(sRGB(0.8)) - + Reflection(0, 0.25) + texture = Texture( + pigment = sRGB(x/size, y/size, z/size), + finish = Ambient(sRGB(0.25)) + + Diffuse(sRGB(0.8)) + + Reflection(0, 0.25) + ) ) - ) size = 10 for x in range(size): for y in range(size): for z in range(size): - objects.append(make_sphere(x, y, z, size)) + objects.append(ShinySphere(x, y, z, size)) recursion_limit = 2*size |