I have that drawing logic:
Draw = function(canvas, ctx, mousePosition) {
var grad = ctx.createLinearGradient(0, 0, canvas[0].width, 0);
grad.addColorStop(0, currentLineColor);
grad.addColorStop(1, currentLineColor);
ctx.lineWidth = currentLineWidth;
ctx.strokeStyle = grad;
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
ctx.globalAlpha = 0.4;
ctx.beginPath();
ctx.moveTo(lastMousePosition.x, lastMousePosition.y);
ctx.lineTo(mousePosition.x, mousePosition.y);
ctx.stroke();
};
When i set the globalAlpha to set opacity in this code a see dots in my drawn line. This logic is attached to mosemove event.