0
반원의이 애니메이션을 그렸습니다. 기본적으로이 애니메이션을 복사하고 60px 아래로 복사 한 다음 새로운 하나의 지연을 추가하기를 원합니다. 에 "B"어떻게 캔버스에 애니메이션을 복사합니까
<canvas id="thecanvas"></canvas>
다음 스크립트
var can = document.getElementById('thecanvas');
ctx = can.getContext('2d');
can.width = window.innerWidth;
can.height = window.innerHeight;
window.drawCircle = function (x, y) {
segments = 90, /* how many segments will be drawn in the space */
currentSegment = 0,
toRadians = function (deg) {
return (Math.PI/180) * deg;
},
getTick = function (num) {
var tick = toRadians(180)/segments; /*360=full, 180=semi, 90=quarter... */
return tick * num;
},
segment = function (end) {
end = end || getTick(currentSegment);
ctx.clearRect(0, 0, can.width, can.height);
ctx.beginPath();
ctx.arc(x, y, 60, (1.5 * Math.PI), end + (1.5 * Math.PI), false);
ctx.stroke();
ctx.closePath();
};
ctx.lineWidth = 5;
ctx.strokeStyle = 'rgba(0,0,0,0.5)';
setTimeout(function render() {
segment(getTick(currentSegment));
currentSegment += 1;
if (currentSegment < segments) {
setTimeout(render, 5);
} else {
currentTick = 0;
}
}, 250);
};
drawCircle(100, 100);
는 바이올린에게 있습니다
HTML을 그립니다 http://jsfiddle.net/zhirkovski/bJqdN/