Simplified redraw

This commit is contained in:
Luis Leiva 2019-07-23 09:57:49 +03:00
parent e18f23123e
commit be740d5c60
2 changed files with 30 additions and 42 deletions

View File

@ -687,36 +687,30 @@
} }
if (t === 0) { if (t === 0) {
sketch.beginPath();
// Draw first point of stroke. // Draw first point of stroke.
if (options.graphics.firstPointSize > 0) { if (options.graphics.firstPointSize > 0) {
sketch.beginFill(lineColor) sketch.beginFill(options.graphics.fillStyle)
.fillCircle(currPt[0], currPt[1], options.graphics.firstPointSize) .fillCircle(currPt[0], currPt[1], options.graphics.firstPointSize)
.endFill(); .endFill();
} }
} // Set line styles.
var lc, lw;
// Connect consecutive points with lines.
if (nextPt) {
var lineColor, lineWidth;
if (isDrawing) { if (isDrawing) {
// Style for regular, pendown strokes. // Style for regular, pendown strokes.
lineColor = options.strokeStyle; lc = options.strokeStyle;
lineWidth = options.lineWidth; lw = options.lineWidth;
} else if (options.mouseupMovements) { } else if (options.mouseupMovements) {
// Style for penup strokes. // Style for penup strokes.
lineColor = options.mouseupMovements.strokeStyle || '#DDD'; lc = options.mouseupMovements.strokeStyle || '#DDD';
lineWidth = options.mouseupMovements.lineWidth || 1; lw = options.mouseupMovements.lineWidth || 1;
} }
sketch.lineStyle(lc, lw);
sketch.lineStyle(lineColor, lineWidth) } else if (nextPt) {
// Connect consecutive points with lines.
sketch.beginPath()
.line(currPt[0], currPt[1], nextPt[0], nextPt[1]) .line(currPt[0], currPt[1], nextPt[0], nextPt[1])
.stroke(); .stroke()
} .closePath();
// Flag stroke change.
if (t === stroke.length - 1) {
sketch.closePath();
} }
} }
} }

View File

@ -682,36 +682,30 @@
} }
if (t === 0) { if (t === 0) {
sketch.beginPath();
// Draw first point of stroke. // Draw first point of stroke.
if (options.graphics.firstPointSize > 0) { if (options.graphics.firstPointSize > 0) {
sketch.beginFill(lineColor) sketch.beginFill(options.graphics.fillStyle)
.fillCircle(currPt[0], currPt[1], options.graphics.firstPointSize) .fillCircle(currPt[0], currPt[1], options.graphics.firstPointSize)
.endFill(); .endFill();
} }
} // Set line styles.
var lc, lw;
// Connect consecutive points with lines.
if (nextPt) {
var lineColor, lineWidth;
if (isDrawing) { if (isDrawing) {
// Style for regular, pendown strokes. // Style for regular, pendown strokes.
lineColor = options.strokeStyle; lc = options.strokeStyle;
lineWidth = options.lineWidth; lw = options.lineWidth;
} else if (options.mouseupMovements) { } else if (options.mouseupMovements) {
// Style for penup strokes. // Style for penup strokes.
lineColor = options.mouseupMovements.strokeStyle || '#DDD'; lc = options.mouseupMovements.strokeStyle || '#DDD';
lineWidth = options.mouseupMovements.lineWidth || 1; lw = options.mouseupMovements.lineWidth || 1;
} }
sketch.lineStyle(lc, lw);
sketch.lineStyle(lineColor, lineWidth) } else if (nextPt) {
// Connect consecutive points with lines.
sketch.beginPath()
.line(currPt[0], currPt[1], nextPt[0], nextPt[1]) .line(currPt[0], currPt[1], nextPt[0], nextPt[1])
.stroke(); .stroke()
} .closePath();
// Flag stroke change.
if (t === stroke.length - 1) {
sketch.closePath();
} }
} }
} }