From cebddea1bf3e27be12b0b80ddaa2c099e21d3d72 Mon Sep 17 00:00:00 2001
From: Neil Gershenfeld <gersh@cba.mit.edu>
Date: Sun, 19 Jan 2020 22:55:37 +0530
Subject: [PATCH] path rastering

---
 modules/processes/mill/raster/3D | 58 ++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 17 deletions(-)

diff --git a/modules/processes/mill/raster/3D b/modules/processes/mill/raster/3D
index aaa3a83..c7ed5b1 100644
--- a/modules/processes/mill/raster/3D
+++ b/modules/processes/mill/raster/3D
@@ -227,26 +227,50 @@ function calculate_path() {
    //
    // line loop
    //
-   var step = 1
    var ix = 0
-   var iy = 10
-   var x1 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
-   var y1 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
+   var iy = mod.height-1
+   var dx = 1
+   var dy = 0
+   //var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
+   //var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
    while (1) {
-      ix += step
-      if (ix == mod.width)
+      var ixp = ix
+      var iyp = iy
+      ix += dx
+      iy += dy
+   var line = document.createElementNS('http://www.w3.org/2000/svg','line')
+   line.setAttribute('stroke','black')
+   line.setAttribute('stroke-width',1)
+   line.setAttribute('stroke-linecap','round')
+            line.setAttribute('x1',ixp)
+            line.setAttribute('y1',iyp)
+            line.setAttribute('x2',ix)
+            line.setAttribute('y2',iy)
+   g.appendChild(line)
+      //var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
+      //var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
+      if (iy <= 0)
          break;
-      var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
-      var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
-      var line = document.createElementNS('http://www.w3.org/2000/svg','line')
-      line.setAttribute('stroke','black')
-      line.setAttribute('stroke-width',1)
-      line.setAttribute('stroke-linecap','round')
-      line.setAttribute('x1',x1)
-      line.setAttribute('y1',y1)
-      line.setAttribute('x2',x2)
-      line.setAttribute('y2',y2)
-      g.appendChild(line)
+      if (ix == (mod.width-1)) {
+         if (dx == 1) {
+            dx = 0
+            dy = -10
+            }
+         else {
+            dx = -1
+            dy = 0
+            }
+         }
+      else if (ix == 0) {
+         if (dx == -1) {
+            dx = 0
+            dy = -10
+            }
+         else {
+            dx = 1
+            dy = 0
+            }
+         }
       }
    mod.label.nodeValue = 'calculate'
    mod.labelspan.style.fontWeight = 'normal'
-- 
GitLab