From 67976418a37fed484b2e6969eee9c43e8fb24e46 Mon Sep 17 00:00:00 2001 From: Rick Companje Date: Mon, 2 Feb 2015 13:36:31 +0100 Subject: [PATCH] hide travel-lines in canvas and preview --- js/canvasDrawing.js | 13 +++++++++---- js/previewRendering.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/js/canvasDrawing.js b/js/canvasDrawing.js index cfe70cc..db9a6d0 100644 --- a/js/canvasDrawing.js +++ b/js/canvasDrawing.js @@ -39,6 +39,8 @@ var lineweight = 2; var isModified = false; +var showTravelLines = false; + /* * * * * * * * * * * * INIT @@ -98,8 +100,6 @@ function initDoodleDrawing() { * * * * * * * * * * */ function draw(_x, _y, _width) { - //console.log("canvasDrawing:draw"); - // console.log("f:draw() >> _width: " + _width); if (prevX == 0 && prevY ==0) { prevX = _x; @@ -108,7 +108,12 @@ function draw(_x, _y, _width) { ctx.beginPath(); ctx.moveTo(prevX, prevY); - ctx.lineTo(_x, _y); + + if (showTravelLines || _width==undefined) { //when _width=0.5 it's a travel line, when it's not supplied it's a real line. + ctx.lineTo(_x, _y); + } else { + ctx.moveTo(_x, _y); + } if (_width != undefined) { ctx.lineWidth = _width; @@ -202,7 +207,7 @@ function redrawDoodle(recalcBoundsAndTransforms) { for (var i = 0; i < _points.length; i++) { // console.log(" drawing points " + _points[i]); if (_points[i][2] == true) { - draw(_points[i][0], _points[i][1], 0.5); + draw(_points[i][0], _points[i][1], 0.5); //draw moves as thin lines } else { draw(_points[i][0], _points[i][1]); } diff --git a/js/previewRendering.js b/js/previewRendering.js index aba2d6a..db74c44 100644 --- a/js/previewRendering.js +++ b/js/previewRendering.js @@ -16,7 +16,8 @@ var previewCtx_tmp; var previewDefaults = { rotation: 0, //Math.PI/90, - numLayers: 10 + numLayers: 5, //was 10 + showTravelLines: false } var svgPathRegExp = /[LM]\d* \d*/ig; @@ -189,7 +190,12 @@ function renderToImageDataPreview() { previewCtx_tmp.moveTo(adjustedDoodlePt.x, adjustedDoodlePt.y); for(var j = 1; j < _points.length; j++) { adjustedDoodlePt = centeredAndScaledDoodlePoint(_points[j]) - previewCtx_tmp.lineTo(adjustedDoodlePt.x, adjustedDoodlePt.y); + + if (!previewDefaults.showTravelLines && _points[j][2]==true) { + previewCtx_tmp.moveTo(adjustedDoodlePt.x, adjustedDoodlePt.y); + } else { + previewCtx_tmp.lineTo(adjustedDoodlePt.x, adjustedDoodlePt.y); + } } previewCtx_tmp.stroke(); previewCtx_tmp.closePath(); @@ -303,6 +309,7 @@ function centeredAndScaledDoodlePoint(p) { var updatePrevX = -1; var updatePrevY = -1; function updatePreview(_x, _y, redrawLess) { + //console.log("PreviewRendering:updatePreview"); if (redrawLess == undefined) redrawLess = false; redrawLess = false;