<head>
<meta charset=utf-8 />
</head>
<body>
<canvas id="circle" width="500" height="500" style="border:1px solid grey"></canvas>
<br>
Радиус
<br>
<input type="text" id="radius" value="50">
<br>
Толщина
<br>
<input type="text" id="thickness" value="50">
<br>
<input type="button" onclick="draw()" value="нарисовать">
<script>
function draw()
{
let canvas = document.getElementById('circle');
let ctx = canvas.getContext('2d');
let X = canvas.width / 2;
let Y = canvas.height / 2;
let R = Number(document.getElementById('radius').value);
ctx.fillStyle = '#ffffff';
ctx.fillRect(0,0,500,500);
ctx.beginPath();
ctx.arc(X,Y, R, 0, 2 * Math.PI, false);
ctx.strokeStyle = '#FF0000';
ctx.stroke();
let thickness = Number(document.getElementById('thickness').value);
for (let i = 0; i <thickness;i++){
ctx.arc(X,Y, R, 0, 2 * Math.PI, false);
ctx.strokeStyle = '#FF0000';
ctx.stroke();
R = R + 1;
}
}
</script>
</body>
|