From 93d72731d09e97696c846f92199a79c2240b034a Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Wed, 27 Apr 2016 01:31:07 -0400
Subject: [PATCH] add grid to background

---
 externals/miXed/cyclone/sickle/Scope.c |  3 ---
 pd/nw/pdgui.js                         | 21 ++++++++++++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/externals/miXed/cyclone/sickle/Scope.c b/externals/miXed/cyclone/sickle/Scope.c
index 5e5074b4f..fdc382f33 100644
--- a/externals/miXed/cyclone/sickle/Scope.c
+++ b/externals/miXed/cyclone/sickle/Scope.c
@@ -722,9 +722,6 @@ static void scope_drawbg(t_scope *x, t_canvas *cv,
 	sys_vgui(".x%x.c create line %d %f %d %f\
  -width %f -tags {%s %s}\n", cv, x1, yy, x2, yy,
 		 SCOPE_GRIDWIDTH, x->x_gridtag, x->x_tag);
-// parameters for GUI message:
-// cv = canvas
-// x2 - x1, y2 - y1, bgcolor SCOPE_GRIDWIDTH, dx, dy
     gui_vmess("gui_scope_draw_bg", "xxsiifff",
         glist_getcanvas(cv),
         x,
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 91ce60302..157310a23 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -3050,8 +3050,27 @@ function gui_scope_draw_bg(cid, tag, bg_color, w, h, grid_width, dx, dy) {
             fill: bg_color,
             stroke: "black",
             "stroke-width": grid_width
-        });
+        }),
+        path,
+        path_string = "",
+        i, x, y, align_x, align_y;
+    for (i = 0, x = dx; i < 7; i++, x += dx) {
+        align_x = (x|0) === x ? x : Math.round(x);
+        path_string += ["M", 0, 0, align_x, 0, align_x, h].join(" ");
+    }
+    for (i = 0, y = dy; i < 3; i++, y += dy) {
+        align_y = (y|0) === y ? y : Math.round(y);
+        path_string += ["M", 0, 0, 0, align_y, w, align_y].join(" ");
+    }
+    path = create_item(cid, "path", {
+        d: path_string,
+        fill: "none",
+        stroke: "black",
+        "stroke-width": grid_width,
+        "shape-rendering": "geometricPrecision"
+    });
     g.appendChild(bg);
+    g.appendChild(path);
 }
 
 function add_popup(cid, popup) {
-- 
GitLab