Advertisement
Guest User

Untitled

a guest
May 25th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function initializeDrawing() {
  2.     var c = document.getElementById("myCanvas");
  3.     var ctx = c.getContext("2d");
  4.    
  5.     // Pravougaonik
  6.     ctx.fillStyle = "#FF0000";
  7.     ctx.fillRect(0,0,150,75);
  8.    
  9.     // Linija
  10.     ctx.moveTo(150,0);
  11.     ctx.lineTo(300,75);
  12.     ctx.stroke();
  13.    
  14.     // Krug
  15.     ctx.beginPath();
  16.     ctx.arc(350,40,40,0,2*Math.PI);
  17.     ctx.stroke();
  18.     ctx.closePath();
  19.    
  20.     // Luk
  21.     ctx.beginPath();
  22.     ctx.arc(390,40,40,0,0.33*Math.PI);
  23.     ctx.stroke();
  24.     ctx.closePath();
  25.    
  26.     // Tekst
  27.     ctx.font = "30px Arial";
  28.     ctx.fillText("Hello World",460,50);
  29.    
  30.     // Gradijent
  31.     var grd = ctx.createLinearGradient(0,0,200,0);
  32.     grd.addColorStop(0,"blue");
  33.     grd.addColorStop(1,"white");
  34.  
  35.     ctx.fillStyle = grd;
  36.     ctx.fillRect(10,150,150,80);
  37.    
  38.     // Kruzni gradijent
  39.     var grd = ctx.createRadialGradient(285,190,20,285,190,100);
  40.     grd.addColorStop(0,"red");
  41.     grd.addColorStop(1,"white");
  42.  
  43.     ctx.fillStyle = grd;
  44.     ctx.fillRect(210,150,150,80);
  45.    
  46.     // Slika
  47.     var img=document.getElementById("canvas-image");
  48.     ctx.drawImage(img, 10, 300);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement