From bb472b7c86cedc0c56e7aadb61297ba3071637b0 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Sat, 27 Feb 2016 01:11:22 -0500
Subject: [PATCH] simplify the function call for redrawing message box bordre

---
 pd/nw/pdgui.js  | 29 ++++++++++++++++-------------
 pd/src/g_text.c |  6 ++----
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 7618b521e..aa8d07b7a 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -1432,18 +1432,22 @@ function gui_gobj_highlight_io(cid, tag) {
     }
 }
 
-function gui_message_draw_border(cid,tag,width,height) {
+function message_border_points(width, height) {
+    return [0,0,
+            width+4, 0,
+            width, 4,
+            width, height-4,
+            width+4, height,
+            0, height,
+            0, 0]
+        .join(" ");
+}
+
+function gui_message_draw_border(cid, tag, width, height) {
     var g = get_gobj(cid, tag),
-        p_array = [0,0,
-                   width+4, 0,
-                   width, 4,
-                   width, height-4,
-                   width+4, height,
-                   0, height,
-                   0, 0],
         polygon;
     polygon = create_item(cid, "polygon", {
-        points: p_array.join(),
+        points: message_border_points(width, height),
         fill: "none",
         stroke: "black",
         class: "border"
@@ -1461,12 +1465,11 @@ function gui_message_flash(cid, tag, state) {
     }
 }
 
-function gui_message_redraw_border(cid,tag,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14) {
+function gui_message_redraw_border(cid, tag, width, height) {
     var g = get_gobj(cid, tag),
-        b = g.querySelector(".border"),
-        p_array = [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14];
+        b = g.querySelector(".border");
     configure_item(b, {
-        points: p_array.join(" "),
+        points: message_border_points(width, height),
     });
 }
 
diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 6c6814fdb..45af30609 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -2192,10 +2192,8 @@ void text_drawborder(t_text *x, t_glist *glist,
             //    x1, y1,  x2+4, y1,  x2, y1+4,  x2, y2-4,  x2+4, y2,
             //    x1, y2,  x1, y1);
             /* These coords can be greatly simplified, as above... */
-            gui_vmess("gui_message_redraw_border", "xsiiiiiiiiiiiiii",
-                glist_getcanvas(glist), tag,
-                x1-x1, y1-y1,  x2+4-x1, y1-y1,  x2-x1, y1+4-y1, x2-x1, y2-4-y1,  x2+4-x1, y2-y1,
-                x1-x1, y2-y1,  x1-x1, y1-y1);
+            gui_vmess("gui_message_redraw_border", "xsii",
+                glist_getcanvas(glist), tag, x2 - x2, y2 - y1);
         }
     }
     else if (x->te_type == T_ATOM)
-- 
GitLab