function drawLine(ctx, sX, sY, eX, eY, sRGB, fRGB, lWidth, capStyle)
{
ctx.beginPath();
ctx.moveTo(sX, sY);
ctx.lineTo(eX, eY);
ctx.lineWidth = lWidth||5;
ctx.strokeStyle = 'rgb(49, 129, 48)';
ctx.lineCap = 'round';
ctx.stroke();
ctx.closePath();
}
And then I want to call the function like this:
drawLine(ctx, 50, 50, 100, 100, someStrokeStyle, someFillStyle, someCapStyle);
As you can see I have skipped the lWidth
parameter. I want the function to still work, even when the lWidth
is not passed as a parameter. How will I do this? Atm, it might think that the someCapStyle
is the lwidth
.