canvas test

by jdias

HTML

<script src="http://explorercanvas.googlecode.com/svn/trunk/excanvas.js"></script>
<canvas id="cv" width="100" height="100"></canvas>
<br/>
<button onclick="draw()">draw</button>

JavaScript

function draw() {
    var cv = document.getElementById('cv');
    var ct = cv.getContext('2d');
    //ct.save();
    
    var w = cv.width;
    var h = cv.height;
    
    ct.clearRect(0, 0, w, h);
    ct.fillStyle = 'rgba(0, 255, 0, 1.0)';
    ct.fillRect(0, 0, w, h);
    
    ct.strokeStyle = 'rgba(127, 127, 255, 1.0)';
    ct.fillStyle = 'rgba(0, 0, 255, 1.0)';
    ct.lineWidth = 5;
    ct.beginPath();
    ct.arc(w/2, h/2, w/2, h/2, 0, 2*Math.PI, 0);
    ct.closePath();
    //ct.stroke();
    ct.fill();
    
    //ct.restore();
}