📜  如何在画布中绘制水平线 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:09.960000             🧑  作者: Mango

代码示例1
const canvas = document.querySelector('.main-canvas');
const ctx = canvas.getContext('2d');

let lineWidth = 33;
let totalWidth = canvas.width;
let middle = canvas.width / 2;

ctx.beginPath();
ctx.moveTo(0, middle);
ctx.lineTo(totalWidth, middle);
ctx.stroke();