Код: Выделить всё
function draw(x, y, radius, col) {
for (let j = 0; j < radius; j++) {
for (let i = 0; i < 360; i += 1) {
let angle = Math.PI / 180 * i;
let cos = x + Math.cos(angle) * j;
let sin = y + Math.sin(angle) * j;
ctx.strokeStyle = col;
ctx.beginPath();
ctx.moveTo(cos, sin);
ctx.lineTo(cos + 1, sin + 1);
ctx.stroke();
}
}
}
const ctx = document.querySelector('canvas').getContext('2d');
draw(ctx.canvas.width / 2, ctx.canvas.height / 2, ctx.canvas.width / 2, 'red')< /code>
Вывод этого можно увидеть на изображении ниже:
Подробнее здесь: https://stackoverflow.com/questions/795 ... javascript