Daha önce tuvalde çizilmiş bir ifadeyi hareketlendirmeye çalışıyorum. Bir çizim yapmaya ve bir öğreticiyi izleyen kareleri kullanarak temizlemeye çalışıyorum ancak sonuç almıyorum. Kodlanmış ifade kodunun 6 karesi var ve kodun içine nasıl ekleneceğinden emin değilim. Ben animasyon ile zor bir zaman var gibi ben bile doğru yolda olup olmadığımıHTML5 tuvalinde animasyonla göz kırpmak için bir ifade animasyonu
<!DOCTYPE html>
<html>
<head>
<title>Adding Animation</title>
<style>
canvas {
border: 3px #CCC solid;
}
</style>
</head>
<body>
<div id="container">
<canvas id="myCanvas" height="1200" width="900"></canvas>
</div>
<script>
var mainCanvas = document.querySelector("#myCanvas");
var mainContext = mainCanvas.getContext("2d");
var canvasWidth = mainCanvas.width;
var canvasHeight = mainCanvas.height;
function drawCircle() {
mainContext.clearRect(0, 0, canvasWidth, canvasHeight);
// color in the background
mainContext.fillStyle = "#EEEEEE";
mainContext.fillRect(0, 0, canvasWidth, canvasHeight);
// draw the circle
ctx.beginPath();
ctx.strokeStyle = "000000";
ctx.lineWidth = 5;
ctx.fillStyle = "yellow";
ctx.arc(600, 450, 150, 0, Math.PI * 2, true);
ctx.stroke();
ctx.closePath();
ctx.fill();
//The smile
ctx.beginPath();
ctxstrokeStyle = "black";
ctx.lineWidth = 2;
ctx.arc(600, 475, 75, .1 * Math.PI, Math.PI * .9, false)
ctx.stroke();
ctx.closePath();
//The eyes
//Left
ctx.save();
ctx.scale(0.65, 1);
ctx.beginPath();
ctx.arc(850, 405, 40, 0 * Math.PI, Math.PI * 2, false);
ctx.fillStyle="black";
ctx.fill();
ctx.stroke();
ctx.closePath();
ctx.restore();
//Right
ctx.save();
ctx.scale(0.65, 1);
ctx.beginPath();
ctx.arc(1000,405,40, 0*Math.PI, Math.PI*2, false);
ctx.fillStyle="black";
ctx.fill();
ctx.stroke();
ctx.closePath();
ctx.restore()
}
drawCircle();
</script>
</body>
</html>
emin oldum: Bu defa ne var. Bana rehberlik edebileceği önerileri olan var mı?
Animasyonu tersine çevirerek gözünüzü "açık" olarak nasıl yedeklersiniz? – phoenixCoder
@phoenixCoder. Evet, bu tam olarak doğru ... göz tamamen kapandığında sadece animasyonu tersine çevir. Göz kırptığını ve gözünü açtığını gösteren demoyu düzenledim. Şerefe! – markE