<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css"></style>
</head>
<body>
<canvas id="canvas"style="border:1px solid #aaa;display:block;margin:50px auto;"></canvas>
<script>
window.onload=function(){
var canvas=document.getElementById("canvas");
canvas.height=768;
canvas.width=1024;
var context=canvas.getContext("2d");
drawRect(context,100,100,400,400,20,"green","red");
}
function drawRect(cxt,x,y,width,height,borderWidth,borerColor,fillColor){
cxt.beginPath();
cxt.moveTo(x,y);
cxt.lineTo(x + width,y);
cxt.lineTo(x + width,y + height);
cxt.lineTo(x,y + height);
cxt.lineTo(x,y);
cxt.closePath();
cxt.lineWidth="borderWidth";
cxt.fillStyle="fillColor";
cxt.strokeStyle="borerColor";
cxt.fill();
cxt.stroke();
}
</script>
</body>
</html>