如何在javascript中添加多种颜色的雪球&;画布动画

如何在javascript中添加多种颜色的雪球&;画布动画,javascript,html,canvas,Javascript,Html,Canvas,我已经在javascript中使用了fillstyle,我想要多个颜色的雪球,我如何使用它?我尝试过使用多个函数和多个画布,但无法做到这一点,请帮助如果没有代码,很难判断,但我猜每次您想绘制不同的颜色时,您都没有使用ctx.beginPath() var ctx=can.getContext(“2d”); ctx.fillStyle=“红色”; ctx.beginPath(); 弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2

我已经在javascript中使用了fillstyle,我想要多个颜色的雪球,我如何使用它?我尝试过使用多个函数和多个画布,但无法做到这一点,请帮助

如果没有代码,很难判断,但我猜每次您想绘制不同的颜色时,您都没有使用ctx.beginPath()

var ctx=can.getContext(“2d”);
ctx.fillStyle=“红色”;
ctx.beginPath();
弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2);
ctx.fill();
ctx.fillStyle=“绿色”;
ctx.beginPath();//开辟新的道路
弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2);
ctx.fill();
ctx.fillStyle=“蓝色”;
ctx.beginPath();//开辟新的道路
弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2);
ctx.fill()

没有代码很难说,但我猜您不是每次都在使用ctx.beginPath()来绘制不同的颜色

var ctx=can.getContext(“2d”);
ctx.fillStyle=“红色”;
ctx.beginPath();
弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2);
ctx.fill();
ctx.fillStyle=“绿色”;
ctx.beginPath();//开辟新的道路
弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2);
ctx.fill();
ctx.fillStyle=“蓝色”;
ctx.beginPath();//开辟新的道路
弧(Math.random()*100+10,Math.random()*100+10,10,0,Math.PI*2);
ctx.fill()