Wednesday, July 29, 2015

Web Game : Lines

Line merupakan komponen paling sederhana yang disediakan oleh HTML 5 Canvas. Line dapat dibuat dengan menggunakan method seperti moveTo(), lineTo(), dan stroke().

Contoh:
<html>
    <head>
<style>
        canvas {
            border-width: 1px;
   border-style: solid;        
        }
        </style>
        <script>
            window.onload = function(){
                var canvas = document.getElementById("myCanvas");
                var context = canvas.getContext("2d");
                context.moveTo(100, 150);
                context.lineTo(450, 50);
                context.stroke();        
            };
        </script>
    </head>
    <body>
        <canvas id="myCanvas" width="640" height="480">
        </canvas>
    </body>
</html>

Hasilnya:















.

0 komentar:

Post a Comment

 
Copyright © . Grup Kuliah - Posts · Comments
Powered by Blogger
close
==[ Klik disini 1X ] [ Close ]==