HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
window.onload = function(){
var canvas = document.getElementById('canvas');
if(canvas.getContext){
var context = canvas.getContext('2d');
context.fillStyle = 'rgb(200,0,0)';
context.fillRect(10,10,100,100);
//16진수 색상 코드
context.fillStyle='#0c30c3';
context.fillRect(50,50,100,100);
context.beginPath();
context.arc(250,90,80,0,Math.PI*2,true);
context.closePath();
context.fillStyle = 'Yellow';
context.strokeStyle='blue';
context.fill();
context.stroke();
}else{
alert('브라우저가 캔버스를 지원하지 않습니다.');
}
};
</script>
</head>
<body>
<canvas id="canvas" width="500" height="300"></canvas>
</body>
</html>


결과





+ Recent posts