HTML5 Canvas, shadowColor & shadowBlur

后端 未结 3 1706
抹茶落季
抹茶落季 2021-01-19 14:52

My question is regarding this shadowBlur feature used on the 2nd (outer) rectangle below. The shadowBlur feature is applied to every shape after this rectangle. (If

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 15:14

    Use either this:

    ctx.save();
      ctx.shadowColor="black";
      ctx.shadowBlur = 10;       
      ctx.strokeRect(45,45,210,110); 
    ctx.restore();
    

    Or this:

    ctx.shadowColor="black";
    ctx.shadowBlur = 10;       
    ctx.strokeRect(45,45,210,110); 
    ctx.shadowColor= undefined; 
    ctx.shadowBlur = undefined;       
    

    I am not sure about 'undefined' in second case - something to nullify/reset the value.

提交回复
热议问题