18 Temmuz 2016 Pazartesi

HTML5 CANVAS ÇİZİM PALETİ YAPMA(KALEMLE ÇİZİM YAPMA)


<!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>
        <meta charset="UTF-8">
    <title></title>
    <script>
    window.onload=function(){
         mycanvas=document.getElementById("mycanvas");
         cizim=mycanvas.getContext("2d");
        cizim.beginPath();
       
         }
     
        function eylem(event){
           
        event=window.event;    /*fonksiyondan aldığımız event parametresine windowsun eventini atıyoruz.*/
        pozx=event.clientX;     /*x koordinatını aldık*/
        pozy=event.clientY;     /*y koordinatını aldık*/
       cizim.stroke();/*çizgiyi çiziyoruz*/
       // cizim.lineTo(0,0);  /*çizginin başlangıç noktası */
        cizim.lineTo(pozx,pozy);/*çizginin bitiş noktası */

    }
   
   
   
   
 
</script>
</head>

<body>
    <canvas onmousemove="eylem()" id="mycanvas" height="500" width="500" style="border:1px solid #ccc;"></canvas>
</body>
</html>

Hiç yorum yok:

Yorum Gönder