18 Temmuz 2016 Pazartesi

HTML5 CANVAS RADİAL GRADİENT ÖRNEĞİ

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
    <title>TODO supply a title</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <style>
       
        canvas{
            border:2px solid #999;
         
        }
       
       
    </style>
    <script>
        window.onload=function(){
       var benimtuval=document.getElementById("mycanvas");
       ctx=benimtuval.getContext("2d");
         var renk=ctx.createRadialGradient(70,100,25,90,60,95);  
         renk.addColorStop(0,"white");
         renk.addColorStop(0.5,"blue");
         renk.addColorStop(1,"darkblue");
        ctx.fillStyle=renk;
        ctx.fillRect(0,0,600,400);
        ctx.fillStyle="white";
        for(a=0;a<500;a++){
            var x=600*Math.random();
            var y=400*Math.random();
            var buyuk=2*Math.random();
            var buyuk1=2*Math.random();    
            ctx.fillRect(x,y,buyuk,buyuk1);
           
        }
       
      }
       
     
    </script>

</head>

<body>
    <canvas id="mycanvas" height="400" width="600"></canvas>




</body>
</html>

Hiç yorum yok:

Yorum Gönder