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 as follows:
drawLine(ctx, 50, 50, 100, 100, someStrokeStyle, someFillStyle, someCapStyle);
As you can see, I skipped the lWidth parameter. I want the function to still work, even when lWidth not passed as a parameter. How do i do this? Atm, it might seem that someCapStyle is lWidth .
source share