Source Code:
<html lang="en">
<head>
<title>Smily Javascript Canvas</title>
<style type="text/css">
canvas {
border: 5px solid black;
background-color:#FFCC00;
}
</style>
<script type="text/javascript" >
function smily() {
var cv = document.getElementById('canvas').getContext('2d');
if (cv == 'undefined') alert('canvas failed');
cv.beginPath();
cv.arc(150,150,120,0,Math.PI*2,true);
cv.fillStyle='purple';
cv.fill();
cv.stroke();
cv.closePath();
cv.beginPath();
cv.arc(100,110,10,0,Math.PI*2,true);
cv.arc(200,110,10,0,Math.PI*2,true);
cv.fillStyle='black';
cv.fill();
cv.closePath();
cv.beginPath();
cv.arc(150,125,105,0.6,2.5,false);
cv.stroke();
cv.closePath();
}
</script>
</head>
<body onLoad="smily();">
<canvas id="canvas" width="300" height="300"></canvas>
</body>
</html>
Tidak ada komentar:
Posting Komentar