fillRect(2)


<!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){
//Context 객체가 그림을 그려줌
var context = canvas.getContext('2d');
//채우기 색상 지정
context.fillStyle ='rgb(200,0,0)';
//색이 칠해져 있는 사각형
context.fillRect(10,10,100,100); //x,y,w,h
}else{
alert('브라우저가 캔버스를 지원하지 않습니다.');
}
};
</script>
</head>
<body>
<canvas id="canvas" width="500" height="300"></canvas>
</body>
</html>



결과





+ Recent posts