Notgnoshi / generative

Generative art. A suite of composable tools to generate, transform and visualize WKT geometries
MIT License
25 stars 3 forks source link

Enable tweaking grid tool #151

Closed Notgnoshi closed 1 year ago

Notgnoshi commented 1 year ago

Before

image

After

diff --git a/tools/grid.rs b/tools/grid.rs
index 779440e..c8cd932 100644
--- a/tools/grid.rs
+++ b/tools/grid.rs
@@ -123,8 +123,8 @@ fn main() {
     let max_j = y2j(max_y, delta_y, min_y);

     // Add the nodes
-    for j in 0..max_j {
-        for i in 0..max_i {
+    for j in 0..=max_j {
+        for i in 0..=max_i {
             let x = i2x(i, delta_x, min_x);
             let y = j2y(j, delta_y, min_y);
             let point = Point::new(x, y);
@@ -133,8 +133,8 @@ fn main() {
     }

     // Add the edges
-    for j in 0..max_j {
-        for i in 0..max_i {
+    for j in 0..=max_j {
+        for i in 0..=max_i {
             let current_index = width * j + i;

             if i < (width - 1) {

This produces

image

when using the examples/asemic.sh script.

Notgnoshi commented 1 year ago

Additionally, I think there's something funky going on with the min-x, max-x, min-y, and max-y parameters (w.r.t. off-by-one errors) in the grid, transform, and streamline tools.

In grid in particular, max- isn't actually the maximum x value - it's one step larger, but changing the loops to use inclusive endpoints does weird stuff as above!