From 6a3c991dc21a78471d97a9cfee42052fcd8fda63 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Wed, 8 Dec 2021 23:19:39 -0500 Subject: [PATCH] Add configuration options for fillAngle (default 45 degrees) and fillRandom, which will randomize the angle on every dot drawn. Calling this release 2.1.2. --- README.md | 3 ++- stipple_gen.pde | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d3b1368..ab7af47 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Other variables: ```java public int canvasWidth = 800; public int canvasHeight = 600; -public float canvasScalar = 1.25; +public float canvasScalar = 1.0; public boolean display = true; public int windowWidth = 800; @@ -60,6 +60,7 @@ public boolean gammaCorrection = false; public float gamma = 1.0; public boolean fill = false; +public boolean dot = false; public float line = 1.0; ``` diff --git a/stipple_gen.pde b/stipple_gen.pde index 5727aa0..c744688 100644 --- a/stipple_gen.pde +++ b/stipple_gen.pde @@ -111,6 +111,8 @@ public class Config { public float gamma = 1.0; public boolean fill = false; + public float fillAngle = 45.0; + public boolean fillRandom = false; public boolean dot = false; public float line = 1.0; @@ -285,6 +287,12 @@ public class Config { case "fill" : fill = boolOrDie(name, val); break; + case "fillAngle" : + fillAngle = floatOrDie(name, val); + break; + case "fillRandom" : + fillRandom = boolOrDie(name, val); + break; case "dot" : dot = boolOrDie(name, val); break; @@ -1188,6 +1196,7 @@ void draw () { float dotRad; float dotDiam; float cutoffScaled = 1 - config.cutoff; + float hatchAngle; ArrayList hatchLines; canvas.beginDraw(); @@ -1329,7 +1338,8 @@ void draw () { } canvas.ellipse(px, py, dotDiam, dotDiam); if (!config.dot && config.fill) { - hatchLines = fillCircle(px, py, dotDiam, 45.0, config.line * config.canvasScalar); + hatchAngle = config.fillRandom ? random(0.0, 360.0) : config.fillAngle; + hatchLines = fillCircle(px, py, dotDiam, hatchAngle, config.line * config.canvasScalar); if (hatchLines.size() > 0) { for (float[] linePoints : hatchLines) { canvas.line(linePoints[0], linePoints[1], linePoints[2], linePoints[3]); @@ -1458,7 +1468,8 @@ void draw () { } if (!config.dot && config.fill) { - hatchLines = fillCircle(xTemp, yTemp, dotRad * 2.0, 45.0, config.line); + hatchAngle = config.fillRandom ? random(0.0, 360.0) : config.fillAngle; + hatchLines = fillCircle(xTemp, yTemp, dotRad * 2.0, hatchAngle, config.line); if (hatchLines.size() > 0) { for (float[] linePoints : hatchLines) { rowTemp += "";