// 矩形渲染 export const rectangleRender = ({ ctx, width, height, X, Y, color, lineWidth }) => { ctx.beginPath(); // //设置线条颜色,必须放在绘制之前 ctx.strokeStyle = color; ctx.lineWidth = lineWidth || 2; ctx.strokeRect(X, Y, width, height); return ctx; }; // 图形渲染 export const shapeRender = ({ ctx, width, height, shapeType, X, Y, color, roundY, roundX, roundR, lineWidth }) => { const typeFn = [ () => rectangleRender({ ctx, width, height, X, Y, color, lineWidth }) ]; typeFn[shapeType](); };