DanAlucard

1.- contexto canvas 2d

Dec 27th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.68 KB | None | 0 0
  1. <canvas id="c"> </canvas>
  2. <script>
  3.  
  4.     // declare the two variables at once using a comma
  5.     var canvas_on_screen = document.getElementById("c"),
  6.         context = canvas_on_screen.getContext("2d");
  7.     // now you're ready to draw
  8.    
  9.    
  10.     // x = 10, y = 20, width = 200, height = 100
  11.     // It's a filled rectangle!!
  12.     context.fillStyle = 'yellow';
  13.     context.fillRect(10, 20, 200, 100);
  14.    
  15.    
  16.     // setup the line style
  17.     context.strokeStyle = 'blue';
  18.     context.lineWidth = 5;
  19.     context.lineCap = 'round';
  20.  
  21.     // draw the arc path
  22.     context.arc(100, 50, 20, 0, 1.7*Math.PI, false);
  23.  
  24.     // colour the path
  25.     context.stroke();
  26.  
  27.  
  28. </script>
Add Comment
Please, Sign In to add comment