1. 获取绘图上下文 var mycanvas = document.getElementById('mycanvas'); var context = mycanvas.getContext('2d'); 2. 绘图函数 注:x = positionX y= position Y w = width h = height 绘制矩形: strokeRect(x,y,w,h); -----边框矩形 fillRect(x,y,w,h); ----填充矩形 清除区域: clearRect(x,y,w,…