慕粉3859131
2017-01-10 22:37
为什么我运行的代码随机生成30个圆正常,40个以上就会有不完整的圆?求大神解惑呀
window.onload = function () {
var can = document.getElementById("canvas");
can.width = 800;
can.height = 800;
var ctx = can.getContext("2d");
for(var i = 0; i < 50; i ++){
var r = Math.floor(Math.random() * 255);
var g = Math.floor(Math.random() * 255);
var b = Math.floor(Math.random() * 255);
ctx.fillStyle = "rgb(" + r + "," + g + "," + b + ")";
ctx.beginPath();
ctx.arc(Math.random() * can.width ,Math.random() * can.height ,Math.random() * 100 ,0 ,2 * Math.PI);
ctx.fill();
}
}
111
Canvas绘图详解
72881 学习 · 422 问题
相似问题