Advertisement
eimkasp

Canvas examples

Aug 2nd, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     var canvas = document.getElementById('exampleCanvas'),
  3.     context = canvas.getContext('2d');
  4.  
  5.     // code examples will continue here...
  6.  
  7.  
  8.     // Tekstas
  9.     context.font = 'italic 40px Calibri, sans-serif';
  10.     context.fillText('Hello World!', 50, 50);
  11.     context.beginPath();
  12.     context.moveTo(0,0);
  13.  
  14.     // Liniju piesimas
  15.     for(var i = 0; i < 100; i++) {
  16.         context.lineTo(i*5 * i + 50,i*2 + 5);
  17.     }
  18.    
  19.       context.fillStyle = "red";
  20.   context.fillRect(10, 10, 100, 50);
  21.    
  22.  
  23.     context.strokeStyle = "blue";
  24.     context.strokeRect(5, 5, 50, 50);
  25.     context.lineWidth = 5;
  26.     context.strokeRect(135, 5, 50, 50);
  27.  
  28.     for (var y = 10; y < 100; y += 10) {
  29.         context.moveTo(10, y);
  30.         context.lineTo(90, y);
  31.     }
  32.  
  33.  
  34.     context.stroke();
  35.     context.moveTo(100, 250);
  36.     context.bezierCurveTo(150, 100, 350, 100, 400, 250);
  37.     context.stroke();
  38.  
  39. });
  40.  
  41.  
  42. // Variantas be jquery
  43. document.addEventListner("DOMContentLoaded", function() {
  44.  
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement