From 7bc971167b7ec10db1194941a0a4809d655402c5 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Tue, 3 Aug 2021 00:36:57 -0400 Subject: [PATCH] Made an important change that removes some of the mystery in the scaling values. Originally it was using an arbitrary value of 1536x1056 and was scaled at 800 / canvasWidth (???). Now it will be set to the canvas value, which gives the user control over the final resolution of the SVG. --- header.txt | 4 ++-- stipple_gen.pde | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/header.txt b/header.txt index a8c898e..4c84fdf 100644 --- a/header.txt +++ b/header.txt @@ -9,8 +9,8 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="1536" - height="1056" + width="{{WIDTH}}" + height="{{HEIGHT}}" id="svg2985" version="1.1" inkscape:version="0.48.1 r9760"> diff --git a/stipple_gen.pde b/stipple_gen.pde index da2b7fa..79bdd91 100644 --- a/stipple_gen.pde +++ b/stipple_gen.pde @@ -84,7 +84,7 @@ public class Config { public int canvasWidth = 800; public int canvasHeight = 600; - public float canvasScalar = 2.0; + public float canvasScalar = 1.0; public boolean display = true; public int windowWidth = 800; @@ -1350,9 +1350,14 @@ void draw () { FileOutput = loadStrings("header.txt"); String rowTemp; + for (i = 0; i < FileOutput.length; i++) { + FileOutput[i] = FileOutput[i].replace("{{WIDTH}}", str(config.canvasWidth)); + FileOutput[i] = FileOutput[i].replace("{{HEIGHT}}", str(config.canvasHeight)); + } + //Need to get some background on this. //what are these magic numbers? - float SVGscale = (800.0 / (float) config.canvasHeight); + float SVGscale = 1.0; //(800.0 / (float) config.canvasHeight); //not centering the image is more controllable int xOffset = 0; //(int) (1536 - (SVGscale * config.canvasWidth / 2)); int yOffset = 0; //(int) (1056 - (SVGscale * config.canvasHeight / 2));