use Array.slice

This commit is contained in:
sidorares 2011-07-22 11:07:49 +10:00
parent 4ac7010e45
commit 04744a4a4c

View file

@ -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));
}
});