<canvas id="myCanvas" width="500" height="300"></canvas>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
// Начинаем новый путь
ctx.beginPath();
// Перемещаем "курсор" в точку (50, 50)
ctx.moveTo(50, 50);
// Добавляем линию от текущей позиции до указанной точки (100, 100)
ctx.lineTo(100, 100);
// Закрываем путь
ctx.closePath();
// Рисуем контур пути
ctx.strokeStyle = 'blue'; // Цвет контура
ctx.lineWidth = 2; // Толщина линии
ctx.stroke();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.