저는 함수가 호출 될 때마다 중간에서 다른 난수를 생성하는 공을 만들려고합니다. 이 공의 개체를 만들기위한 코드이지만 Math.random 메서드를 넣을 수있는 방법 및 실제 중간에 번호를 그립니다. 어떤 생각있어? 예를 들어중간에 난수가있는 공을 만듭니다 (html canvas 및 javascript)
var c = document.getElementById("canvas");
var ctx = c.getContext("2d");
var ball = {
radius:50,
x:200,
y:150,
color:"#00F",
draw:function() {
var arcStartAngle=0;
var arcEndAngle=2*Math.PI;
ctx.fillStyle=this.color
ctx.beginPath();
ctx.arc(this.x,this.y,this.radius,arcStartAngle,arcEndAngle);
ctx.fill();
}
}
ball.draw();
무엇을 하시겠습니까? 캔버스가 필요하지 않을 수도 있습니다. – Cheery