diff --git a/js/Shape.js b/js/Shape.js
index ebf1c59..a679903 100644
--- a/js/Shape.js
+++ b/js/Shape.js
@@ -25,7 +25,7 @@ function shapeMoveTo(x,y) {
_points.push([x, y, true]);
adjustBounds(x, y);
adjustPreviewTransformation();
- draw(x, y, .5);
+ draw(x, y, -1);
}
function shapeLineTo(x,y) {
diff --git a/js/Svg.js b/js/Svg.js
index 1f93ac6..609d32e 100644
--- a/js/Svg.js
+++ b/js/Svg.js
@@ -116,7 +116,7 @@ function loadFromSvg(svgData) {
adjustBounds(x, y);
adjustPreviewTransformation();
- if (isMove) draw(x, y, .5);
+ if (isMove) draw(x, y, -1);
else draw(x, y);
}
p++;
diff --git a/js/canvasDrawing.js b/js/canvasDrawing.js
index cfe70cc..481e58d 100644
--- a/js/canvasDrawing.js
+++ b/js/canvasDrawing.js
@@ -97,52 +97,67 @@ function initDoodleDrawing() {
* CANVAS DRAWING FUNCTION
*
* * * * * * * * * */
-function draw(_x, _y, _width) {
- //console.log("canvasDrawing:draw");
- // console.log("f:draw() >> _width: " + _width);
- if (prevX == 0 && prevY ==0) {
+//If _width is not specified, it is calculated from the distance between this and the previous point.
+//If _width is negative, the path is 'floating', and only drawn if the setting printer.bottomEnableTraveling is true.
+function draw(_x, _y, _width) {
+ //console.log("canvasDrawing:draw");
+ //console.log("f:draw() >> _width: " + _width);
+
+ if (prevX == 0 && prevY == 0) {
prevX = _x;
prevY = _y;
}
ctx.beginPath();
ctx.moveTo(prevX, prevY);
- ctx.lineTo(_x, _y);
-
- if (_width != undefined) {
- ctx.lineWidth = _width;
- } else {
- if (drawVariableLineWeight) {
- var dist = Math.sqrt(Math.pow((prevX - _x), 2) + Math.pow((prevY - _y), 2));
- if (dist < 10) {
- lineweight += .25;
- } else if (dist < 20) {
- lineweight += .5;
- } else if (dist < 30) {
- lineweight += .75;
- } else if (dist < 50) {
- lineweight += 1;
- } else if (dist < 80) {
- lineweight += 1.5;
- } else if (dist < 120) {
- lineweight += 2.25;
- } else if (dist < 170) {
- lineweight += 3.5;
- } else {
- lineweight += 2;
- }
- lineweight = Math.min(lineweight, 30);
- lineweight *= 0.90;
- lineweight = Math.max(lineweight, 1.0);
+
+ if (_width != undefined && _width < 0) {
+ if (settings['printer.bottomEnableTraveling']) {
+ ctx.moveTo(_x, _y);
} else {
- lineweight = 2;
+ ctx.lineTo(_x, _y);
+ ctx.lineWidth = 0.5;
+ ctx.stroke();
}
+ } else {
+ ctx.lineTo(_x, _y);
- ctx.lineWidth = lineweight;
+ if (_width != undefined) {
+ ctx.lineWidth = _width;
+ } else {
+ if (drawVariableLineWeight) {
+ var dist = Math.sqrt(Math.pow((prevX - _x), 2) + Math.pow((prevY - _y), 2));
+ if (dist < 10) {
+ lineweight += .25;
+ } else if (dist < 20) {
+ lineweight += .5;
+ } else if (dist < 30) {
+ lineweight += .75;
+ } else if (dist < 50) {
+ lineweight += 1;
+ } else if (dist < 80) {
+ lineweight += 1.5;
+ } else if (dist < 120) {
+ lineweight += 2.25;
+ } else if (dist < 170) {
+ lineweight += 3.5;
+ } else {
+ lineweight += 2;
+ }
+ lineweight = Math.min(lineweight, 30);
+ lineweight *= 0.90;
+ lineweight = Math.max(lineweight, 1.0);
+ } else {
+ lineweight = 2;
+ }
+
+ ctx.lineWidth = lineweight;
+ }
+ ctx.lineCap = 'round';
+
+ ctx.stroke();
}
- ctx.lineCap = 'round';
- ctx.stroke();
prevX = _x;
prevY = _y;
@@ -202,7 +217,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], -1);
} else {
draw(_points[i][0], _points[i][1]);
}
@@ -301,7 +316,7 @@ function onCanvasMouseDown(e) {
_points.push([x, y, true]);
adjustBounds(x, y);
adjustPreviewTransformation();
- draw(x, y, 0.5);
+ draw(x, y, -1);
}
var prevPoint = {x:-1, y:-1};
@@ -401,7 +416,7 @@ function onCanvasTouchDown(e) {
_points.push([x, y, true]);
adjustBounds(x, y);
adjustPreviewTransformation();
- draw(x, y, .5);
+ draw(x, y, -1);
movementCounter = 0;
@@ -489,8 +504,3 @@ function onCanvasTouchEnd(e) {
function prevent(e) {
e.preventDefault();
}
-
-
-
-
-
diff --git a/js/gcodeGenerating.js b/js/gcodeGenerating.js
index 98c7380..9ce8e85 100644
--- a/js/gcodeGenerating.js
+++ b/js/gcodeGenerating.js
@@ -20,6 +20,7 @@ function generate_gcode() {
var bottomSpeed = settings["printer.bottomLayerSpeed"];
var firstLayerSlow = settings["printer.firstLayerSlow"];
var bottomFlowRate = settings["printer.bottomFlowRate"];
+ var bottomEnableTraveling = settings["printer.bottomEnableTraveling"];
var travelSpeed = settings["printer.travelSpeed"]
var filamentThickness = settings["printer.filamentThickness"];
var wallThickness = settings["printer.wallThickness"];
@@ -159,8 +160,10 @@ function generate_gcode() {
var isTraveling = !isLoop && i==0;
var doRetract = retractionEnabled && prev.distance(to) > retractionminDistance;
+ //Always travel to first point, then optionally disable traveling for first two layers and use settings for remainder of print.
var firstPointEver = (layer == 0 && i == 0 && j == 0);
- if (firstPointEver || layer > 2 && enableTraveling && isTraveling) { //always travel to first point, then disable traveling for first two layers and use settings for remainder of print
+ var travelingAllowed = firstPointEver || bottomEnableTraveling || layer > 2;
+ if (travelingAllowed && enableTraveling && isTraveling) {
if (!firstPointEver && doRetract) gcode.push("G0 E" + (extruder - retractionamount).toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); //retract
gcode.push("G0 X" + to.x.toFixed(3) + " Y" + to.y.toFixed(3) + " Z" + z.toFixed(3) + " F" + (travelSpeed * 60).toFixed(3));
if (!firstPointEver && doRetract) gcode.push("G0 E" + extruder.toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); // return to normal
diff --git a/js/settings/SettingsWindow.js b/js/settings/SettingsWindow.js
index 274ffed..055bb10 100644
--- a/js/settings/SettingsWindow.js
+++ b/js/settings/SettingsWindow.js
@@ -116,6 +116,10 @@ function SettingsWindow() {
settingsPopup.close();
self.signin();
}
+
+ //FIXME: instead of this rather ugly call, implement events for changes to settings so we can keep code decoupled
+ redrawDoodle(false);
+
_btnOK.removeAttr("disabled");
});
};
diff --git a/www/settings.html b/www/settings.html
index d6d74a7..b472417 100644
--- a/www/settings.html
+++ b/www/settings.html
@@ -99,6 +99,7 @@
mm/s
mm/s
+
* Multiplier for extrusion rate in first few layers