Advertisement
Aveneid

Untitled

May 17th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var canvas = document.getElementById('canvas');
  2. var ctx = canvas.getContext('2d');
  3.  
  4. var canvasWidth = canvas.width;
  5. var canvasHeight =canvas.height;
  6.  
  7.  
  8. var angle = 0;
  9.  
  10. var requestAnimationFrame = window.requestAnimationFrame ||
  11. window.mozRequestAnimationFrame ||
  12. window.webkitRequestAnimationFrame ||
  13. window.msRequestAnimationFrame;
  14.  
  15. function drawBG(){
  16.     ctx.beginPath();
  17.     ctx.moveTo(30,75);
  18.     ctx.lineTo(100,25);
  19.     ctx.lineTo(100,75);
  20.     ctx.fillStyle = 'rgb(255,100,0)';
  21.     ctx.fill();
  22.     ctx.closePath();
  23.    
  24.     ctx.beginPath();
  25.     ctx.moveTo(100,25);
  26.     ctx.lineTo(175,75);
  27.     ctx.lineTo(100,75);
  28.     ctx.closePath();
  29.     ctx.fillStyle = 'rgb(255,120,0)';
  30.     ctx.fill();
  31.    
  32.     ctx.beginPath();
  33.     ctx.arc(100,75,40,0,Math.PI, false);
  34.     ctx.closePath();
  35.     ctx.fillStyle = 'rgb(255,190,0)';
  36.     ctx.fill();
  37.    
  38.     ctx.beginPath();
  39.     ctx.arc(100,75,50,0,Math.PI, false);
  40.     ctx.stroke();
  41.     ctx.closePath();
  42.    
  43.    
  44.     ctx.beginPath();
  45.     ctx.moveTo(95,110);
  46.     ctx.lineTo(105,110);
  47.     ctx.lineTo(100,145);
  48.     ctx.fillStyle = "black";
  49.     ctx.fill();
  50.    
  51.     ctx.beginPath();
  52.     ctx.arc(80,85,5,0,Math.PI, true);
  53.     ctx.stroke();
  54.     ctx.closePath();
  55.    
  56.     ctx.beginPath();
  57.     ctx.arc(120,85,5,0,Math.PI, true);
  58.     ctx.stroke();
  59.     ctx.closePath();
  60.     requestAnimationFrame(drawBG);
  61. }
  62. var mouthHeight=6,mouthWidth=6;
  63.  
  64. function drawCircle(){
  65.     ctx.beginPath();
  66.     var radius = 3 +Math.abs(Math.cos(angle));
  67.     ctx.arc(100, 100, radius, 0, Math.PI * 2, false);
  68.     ctx.closePath();
  69.    
  70.     ctx.fillStyle = "red";
  71.     ctx.fill();
  72.  
  73.     angle +=2*Math.PI/180;
  74.     if(angle>180)
  75.         angle=-180;
  76.    
  77.     requestAnimationFrame(drawCircle);
  78. }
  79.  
  80. drawBG(); drawCircle();
  81.  
  82. // var mouth = document.getElementById('mouth');
  83. // var ctx = mouth.getContext('2d');
  84.  
  85.  
  86.  
  87. drawCircle();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement