summaryrefslogtreecommitdiffstats
path: root/dimension/dimension.in
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-06-16 21:40:18 -0600
committerTavian Barnes <tavianator@gmail.com>2011-06-16 21:42:18 -0600
commit415c34935c58c05b5ca0e99a10198f871a90edf4 (patch)
tree7589888d26bbb4a7e711df020305ef4bff682aba /dimension/dimension.in
parenta2267a685e45593da8687f6dc5fd65e76d0259d3 (diff)
downloaddimension-415c34935c58c05b5ca0e99a10198f871a90edf4.tar.xz
Implement Progress class.
Diffstat (limited to 'dimension/dimension.in')
-rw-r--r--dimension/dimension.in34
1 files changed, 26 insertions, 8 deletions
diff --git a/dimension/dimension.in b/dimension/dimension.in
index dc243ab..1b6c229 100644
--- a/dimension/dimension.in
+++ b/dimension/dimension.in
@@ -21,6 +21,25 @@
import argparse
import os.path
+import sys
+
+# Display a progress bar
+def progress_bar(str, progress):
+ if not _args.quiet:
+ print(str, end = ' ')
+ sys.stdout.flush()
+
+ term_width = terminal_width()
+ width = term_width - (len(str) + 1)%term_width
+ for i in range(width):
+ progress.wait(i/width)
+ print('.', end = '')
+ sys.stdout.flush()
+
+ print()
+ sys.stdout.flush()
+
+ progress.finish()
# Parse the command line
_parser = argparse.ArgumentParser(
@@ -74,6 +93,7 @@ die_on_warnings(_args.strict)
# Defaults
objects = []
lights = []
+camera = PerspectiveCamera()
default_texture = Texture(finish = Ambient(0.1) + Diffuse(0.6))
default_interior = Interior()
background = Black
@@ -110,17 +130,15 @@ if _args.quality is not None:
scene.quality = _args.quality
# Raytrace the scene
-if not _args.quiet:
- if scene.nthreads == 1:
- print("Rendering scene ...")
- else:
- print("Rendering scene (using %d threads) ..." % scene.nthreads)
-
-scene.raytrace()
+if scene.nthreads == 1:
+ render_message = "Rendering scene"
+else:
+ render_message = "Rendering scene (using %d threads)" % scene.nthreads
+progress_bar(render_message, scene.raytrace_async())
# Write the output file
export_timer = Timer()
-canvas.write_PNG(_args.output)
+progress_bar("Writing %s" % _args.output, canvas.write_PNG_async(_args.output))
export_timer.complete()
# Print execution times