gpt4 book ai didi

javascript - 想要我的 Canvas 画一个圆圈但结果是 eclipse

转载 作者:行者123 更新时间:2023-11-29 10:08:42 25 4
gpt4 key购买 nike

<分区>

这是我的 jsfiddle:jsfiddle

我不明白为什么这段代码会导致 eclipse ,请看下面我的代码,这是一个使用 requestAnimationFrame 的动画。

function circleGraph(radius) {
return {
type: 'circle',
radius: radius,
currentAngleAnimate: 0
}
}
$(document).ready(function () {
var canvas = document.getElementById('mycanvas');
var context = canvas.getContext('2d')
var width = canvas.width;
var height = canvas.height;
var circleObj = circleGraph(50);

context.lineWidth = 1;
context.strokeStyle = '#ad2323';
context.fillStyle = '#ad2323';

var draw = function () {
context.clearRect(0, 0, width, height);
context.beginPath();
circleObj.currentAngleAnimate += Math.PI * 2 / 60;
context.arc(width / 2, height / 2, circleObj.radius, -Math.PI / 2, circleObj.currentAngleAnimate, false);
context.stroke();
context.lineTo(width / 2, height / 2);
context.fill();
requestAnimationFrame(draw)
}
requestAnimationFrame(draw);
});

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com