relative
答案 0 :(得分:0)
简单的错误,你需要退出画布笔,当你开始开始圈子
var can = document.getElementById('canvas');
var cn = can.getContext('2d');
cn.fillStyle = 'black';
cn.fillRect(0, 0, can.width, can.height);
class object {
constructor(r,sa,ea) {
this.x = Math.floor(Math.random()*800);
this.y = Math.floor(Math.random()*600);
this.r = r;
this.sa = sa;
this.ea = ea;
console.log('object successfully created')
}
drawcircle(){
//Here is your problem you need to exit your pen here to open new pen
cn.beginPath();
cn.strokeStyle = "white"
cn.arc(this.x,this.y,this.r,this.sa,this.ea,false);
cn.lineWidth = 3;
cn.stroke();
}
}
var i;
for(i = 0 ; i < 100 ; i++) {
var circle = new object(5, 0, Math.PI*2);
circle.drawcircle();
}