| 872 | } |
| 873 | |
| 874 | drawGrid(canvas) { |
| 875 | const ctx = canvas.getContext('2d'); |
| 876 | |
| 877 | ctx.strokeStyle = 'rgba(0, 0, 0, 0.3)'; |
| 878 | ctx.lineWidth = 1; |
| 879 | |
| 880 | // 垂直线 |
| 881 | for (let x = 0; x < canvas.width; x += 1) { |
| 882 | ctx.beginPath(); |
| 883 | ctx.moveTo(x + 0.5, 0); |
| 884 | ctx.lineTo(x + 0.5, canvas.height); |
| 885 | ctx.stroke(); |
| 886 | } |
| 887 | |
| 888 | // 水平线 |
| 889 | for (let y = 0; y < canvas.height; y += 1) { |
| 890 | ctx.beginPath(); |
| 891 | ctx.moveTo(0, y + 0.5); |
| 892 | ctx.lineTo(canvas.width, y + 0.5); |
| 893 | ctx.stroke(); |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | drawExportGrid(canvas, scale) { |
| 898 | const ctx = canvas.getContext('2d'); |