Programmatically use RGBa values in fillStyle in ?

前端 未结 5 558
栀梦
栀梦 2021-01-03 17:13

Using , I want to set the RGBa value of the rectangle using a variable.

for example:

ctx.fillStyle = \"rgba(32, 45, 21, 0         


        
5条回答
  •  难免孤独
    2021-01-03 17:56

    You just need to concatenate the r_a variable to build the string correctly:

    var r_a = 0.3; 
    ctx.fillStyle = "rgba(32, 45, 21, " + r_a + ")"; 
    

提交回复
热议问题