Kombinationen

by basti1012

HTML

<!-- Learn about this code on MDN: https://developer.mozilla.org/de/docs/Web/Guide/HTML/Canvas_Tutorial/Formen_zeichnen -->

<html>
 <body onload="draw();">
   <canvas id="canvas" width="150" height="150"></canvas>
 </body>
</html>

JavaScript

function lachen(a,k){
  
 var canvas = document.getElementById('canvas');
  if (canvas.getContext) {
    var ctx = canvas.getContext('2d');

    // Quadratric curves example
    ctx.beginPath();
    ctx.moveTo(50,100);
   // ctx.quadraticCurveTo(25, 25, 25, 62.5);
 
 // ctx.bezierCurveTo(50, 100,100, 150,150, 100,);
  ctx.bezierCurveTo(50, 100,100,a,150, 100,);
//    ctx.quadraticCurveTo(125, 25, 75, 25);
    ctx.stroke();
  }
  if(k==1){
  if(a<180){
  a++
   setTimeout(function(){lachen(a,k)},100)
   }else{
  k=2
  lachen(a,k)
  }
   }
   console.log('k='+k+' a='+a+'')
   
     if(k==2){
  if(a>100){
  a--
   setTimeout(function(){lachen(a,k)},100)
   }else{
  k=1
  lachen(a,k)
  }
   }
   
   
   
   
   
 }
 lachen(100,1)