18 Temmuz 2016 Pazartesi

HTML5 CANVAS CREATE PATTERN ÖZELLİĞİ (DESENİ ARKA PLANA AKTARDIK)


<!DOCTYPE html>
<html>
    <head>
        <style>
            canvas{

                border:1px solid #d3d3d3;
                /*    background-color: #000;*/
            }
        </style>
    <script>
        window.onload = function () {
           
            benimtuval=document.getElementById("mycanvas");
            ctx=benimtuval.getContext("2d");
            resim=document.getElementById("resim");
            renk=ctx.createPattern(resim,"repeat");//repeat repeat-x repeat-y no-repeat
            ctx.fillStyle=renk;
            ctx.fillRect(0,0,benimtuval.width,benimtuval.height);
        }


    </script>


</head>
<body>
<img id="resim" src="pattern.png" style="display:none"/>
    <canvas id="mycanvas" width="600" height="400" >
        Your browser does not support the HTML5 canvas tag.</canvas>



</body>
</html>

Hiç yorum yok:

Yorum Gönder