慕的地6791964
应该这样:
function drawRect(cxt,x,y,width,height,borderWidth,borderColor,fillColor){
cxt.beginPath();
cxt.moveTo(x,y);
cxt.lineTo(x+width,y);
cxt.lineTo(x+width,y+height);
cxt.lineTo(x,y+height);
cxt.closePath();
cxt.lineWidth = borderWidth;
cxt.fillStyle = fillColor;
cxt.strokeStyle = borderColor;
cxt.fill();
cxt.stroke();
}
调用:drawRect(context,100,100,400,400,10,"#046","pink");
刘小骏
fillRect( )是给矩形内填充颜色,strokeRect( )是绘制矩形边框。
慕码人3182499
context.strokeRect(x,y,width,height);
木叶苓
听了老师这么多课程,受益匪浅,希望老师上传更多的课程,职业生涯中你是我的启蒙老师,带我飞
Da嗒_Sunny
黑色!
lechenging
eabour
喵