From 20db42a9283c95035f8e0a7da0de7d49839dc8b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 21 Apr 2015 06:03:43 -0400 Subject: [PATCH] contrib/inkscape_tools: make rounding to the next power of 2 optional MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/inkscape_tools/src/svg_to_png_and_nit.nit | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/contrib/inkscape_tools/src/svg_to_png_and_nit.nit b/contrib/inkscape_tools/src/svg_to_png_and_nit.nit index 80ba5c4..f9e690b 100644 --- a/contrib/inkscape_tools/src/svg_to_png_and_nit.nit +++ b/contrib/inkscape_tools/src/svg_to_png_and_nit.nit @@ -257,10 +257,11 @@ var opt_out_src = new OptionString("Path to output source file (folder or file)" var opt_assets = new OptionString("Path to assert dir where to put PNG files", "--assets", "-a") var opt_scale = new OptionFloat("Apply scaling to exported images (default at 1.0 of 90dpi)", 1.0, "--scale", "-x") var opt_gamnit = new OptionBool("Target the Gamnit framework (by default it targets Mnit)", "--gamnit", "-g") +var opt_pow2 = new OptionBool("Round the image size to the next power of 2", "--pow2") var opt_help = new OptionBool("Print this help message", "--help", "-h") var opt_context = new OptionContext -opt_context.add_option(opt_out_src, opt_assets, opt_scale, opt_gamnit, opt_help) +opt_context.add_option(opt_out_src, opt_assets, opt_scale, opt_gamnit, opt_pow2, opt_help) opt_context.parse(args) var rest = opt_context.rest @@ -394,12 +395,14 @@ for drawing in drawings do nit_src.write_to(src_file) src_file.close - # Find closest power of 2 - var dx = max_x - min_x - max_x = dx.next_pow2 + min_x + # Find next power of 2 + if opt_pow2.value then + var dx = max_x - min_x + max_x = dx.next_pow2 + min_x - var dy = max_y - min_y - max_y = dy.next_pow2 + min_y + var dy = max_y - min_y + max_y = dy.next_pow2 + min_y + end # Inkscape's --export-area inverts the Y axis. It uses the lower left corner of # the drawing area where as queries return coordinates from the top left. -- 1.7.9.5