I am testing this in Chrome. I tried a line thickness solution from StackOverflow here that did not work.
I have a object called redLine with a position and an array of offset positions. The only thing that is affected is the alpha value. Color and line thickness stays once it is set.
function renderRedLine(){
context.beginPath();
for(j=0; j<redLine.posArr.length; ++j){
var startPoint
if(j===0){
startPoint = redLine.pos
}else{
startPoint = redLine.posArr[j-1]
}
var endPoint = redLine.posArr[j]
let alpha = 1.0 - (j/(redLine.posArr.length-1))
let g = 150 - (10*j)
context.strokeStyle = 'rgba(255, ' + g + ', ' + 0 + ', ' + alpha + ')'
context.lineWidth = j+1
if(j===0){
context.moveTo(startPoint.x, startPoint.y);
}else{
context.lineTo(endPoint.x, endPoint.y);
}
context.stroke();
}
context.closePath();
}