0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-13 06:27:55 +01:00

hide travel-lines in canvas and preview

This commit is contained in:
Rick Companje 2015-02-02 13:36:31 +01:00
parent 9b6535be11
commit 67976418a3
2 changed files with 18 additions and 6 deletions

View File

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

View File

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