Ich versuche, "Buen trabajo" in der Leinwand zu drucken und den Ausdruck um den Mittelpunkt Ursprung drehen. Ich bin mir nicht sicher, wie ich das machen soll. Ich habe versucht, eine Schleife zu erstellen, die Stück für Stück inkrementiert, aber ich denke, ich vermisse etwas.Rotierende Animation in Leinwand
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
function drawGoodJob(){
var counter = 60;//so the object won't run for more than 60 seconds
var increment = 10;//amount to increment the canvas by
while(counter<60){
ctx.rotate(increment*Math.PI/180);
increment+20;
}
drawGoodJob();
ctx.font = "80px Verdana";
// Create gradient
var gradient = ctx.createLinearGradient(0, 0, c.width, 0);
gradient.addColorStop("0", "magenta");
gradient.addColorStop("0.5", "blue");
gradient.addColorStop("1.0", "green");
// Fill with gradient
ctx.strokeStyle = gradient;
ctx.strokeText("Buen trabajo", 150, 400);//strokeText makes the letters hollow
}
</script>
Super hilfreich !!!!! Ich danke dir sehr. – MusicGirl