我試圖用createJS庫動畫的弧線,但我一直有這樣一個錯誤:與createJS弧動畫
Uncaught TypeError: context.graphics.clearRect is not a function
和
Uncaught TypeError: context.graphics.beginPath is not a function
是什麼意思呢?請幫我
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: #f1ecec;
}
canvas {background-color: aliceblue;}
</style>
<script src="https://code.createjs.com/createjs-2015.05.21.min.js"></script>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var stage = new createjs.Stage(canvas);
var context = new createjs.Shape();
var x = 250;
var y = 250;
var radius = 75;
var endPercent = 25 * Math.PI;
var curPerc = Math.PI/2;
var counterClockwise = false;
var circ = Math.PI * 2;
var quart = Math.PI/2;
context.lineWidth = 10;
context.strokeStyle = '#ad2323';
context.shadowOffsetX = 0;
context.shadowOffsetY = 0;
context.shadowBlur = 10;
context.shadowColor = '#656565';
function animate(current) {
context.graphics.clearRect(0, 0, canvas.width, canvas.height);
context.graphics.beginPath();
context.graphics.arc(x, y, radius, -(quart), ((circ) * current) - quart, false);
context.graphics.stroke();
curPerc++;
if (curPerc < endPercent) {
requestAnimationFrame(function() {
animate(curPerc/100)
});
}
}
animate();
</script>
</body>
</html>