From 04744a4a4cab60ac0f36f9ff1aea8a4d057e0401 Mon Sep 17 00:00:00 2001 From: sidorares Date: Fri, 22 Jul 2011 11:07:49 +1000 Subject: [PATCH] use Array.slice --- test/polyline.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/test/polyline.js b/test/polyline.js index 24095a9..1509ac0 100644 --- a/test/polyline.js +++ b/test/polyline.js @@ -30,19 +30,13 @@ xclient.on('connect', function(display) { X.on('event', function(ev) { if (ev.type == 12) { - if (pts.length > 2) + if (pts.length > 4) X.PolyLine(0, wid, gc, pts); } else if (ev.type == 6) { - //pts.push(ev.x); - //pts.push(ev.y); - - //if (prevPoint) - // X.PolyLine(0, wid, gc, [prevPoint.x, prevPoint.y, ev.x, ev.y]); - // - //prevPoint = { x: ev.x, y: ev.y }; - - //if (pts.length > 2) - // X.PolyLine(0, wid, gc, pts); + pts.push(ev.x); + pts.push(ev.y); + if (pts.length > 4) + X.PolyLine(0, wid, gc, pts.slice(-4)); } });