From 1c9b8fa88e290ef2b66f049c99b812f378d30ee3 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 16 Jun 2011 00:03:37 -0600 Subject: Use types for command-line options, and support --quality. --- dimension/dimension.in | 18 +++++++++++------- libdimension-python/dimension.pyx | 9 ++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dimension/dimension.in b/dimension/dimension.in index 1f26db0..b73ff1c 100644 --- a/dimension/dimension.in +++ b/dimension/dimension.in @@ -32,10 +32,10 @@ _parser = argparse.ArgumentParser( _parser.add_argument('-V', '--version', action = 'version', version = '@PACKAGE_NAME@ @PACKAGE_VERSION@') -_parser.add_argument('-w', '--width', action = 'store', default = 768, - help = 'image width') -_parser.add_argument('-h', '--height', action = 'store', default = 480, - help = 'image height') +_parser.add_argument('-w', '--width', action = 'store', type = int, + default = 768, help = 'image width') +_parser.add_argument('-h', '--height', action = 'store', type = int, + default = 480, help = 'image height') _parser.add_argument('-v', '--verbose', action = 'store_true', help = 'print more information') @@ -44,12 +44,14 @@ _parser.add_argument('-q', '--quiet', action = 'store_true', _parser.add_argument('--strict', action = 'store_true', help = 'treat warnings as errors') -_parser.add_argument('--threads', action = 'store', +_parser.add_argument('--threads', action = 'store', type = int, help = 'the number of threads to render with') +_parser.add_argument('--quality', action = 'store', type = int, + help = 'the scene quality') -_parser.add_argument('-o', '--output', action = 'store', +_parser.add_argument('-o', '--output', action = 'store', type = str, help = 'the output image file') -_parser.add_argument('input', action = 'store', +_parser.add_argument('input', action = 'store', type = str, help = 'the input scene description file') _args = _parser.parse_args() @@ -101,6 +103,8 @@ if recursion_limit is not None: scene.recursion_limit = recursion_limit if _args.threads is not None: scene.nthreads = _args.threads +if _args.quality is not None: + scene.quality = _args.quality # Raytrace the scene if not _args.quiet: diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index fa57691..b19db18 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -432,7 +432,7 @@ cdef class Canvas: """A rendering target.""" cdef dmnsn_canvas *_canvas - def __init__(self, size_t width, size_t height): + def __init__(self, width, height): """ Create a Canvas. @@ -1292,6 +1292,13 @@ cdef class Scene: def __set__(self, n): self._scene.nthreads = n + property quality: + """The render quality.""" + def __get__(self): + return self._scene.quality + def __set__(self, q): + self._scene.quality = q + property bounding_timer: """The Timer for building the bounding hierarchy.""" def __get__(self): -- cgit v1.2.3