Good day to all! There is such an interesting task - to draw a circle using html and js. In essence, the task is to create a div on the markup of a certain width / height. I can offer the method itself because there is a way to draw such a rhombus
var obj = document.getElementById('container'); var tmp, k = 0, m = 200; for (var i = 0; i <= m; i++) { if (i > m / 2) k--; else k++; tmp = document.createElement('div'); //tmp.style.border = '1px solid #111fff' tmp.style.width = k + 'px'; tmp.style.height = '1px'; obj.appendChild(tmp); } #container { width: 100%; display: block; padding: 10px; } #container div { background-color: lightblue; margin: 0 auto; } <div id="container"></div> But I would like to ask for help in drawing a circle in this way. How to create an algorithm that draws a circle line by line with divs? I tried to do it with the formula c = 2R * sin (angle / 2), where c is the distance between points on the circle, and angle is the angle in radians. But it turns out a drop, not a circle. Code "drops":
var obj = document.getElementById('container1'); var tmp, k = 0, m = 300, angl = 0; for (var i = 0; i <= m; i++) { if (angl > 360) angl = 360; tmp = document.createElement('div'); var sinus = Math.sin((Math.PI * angl / 180) / 2); tmp.style.width = m * sinus + 'px'; tmp.style.height = '1px'; obj.appendChild(tmp); var nexAngle = 360 / m; angl += nexAngle; } #container, #container1 { width: 100%; display: block; padding: 10px; } #container1 div { background-color: lightgreen; margin: 0 auto; } <div id="container1"></div> PS code is very ugly. done "in the forehead")
UPD: @pavel and @Gleb Kemarsky both answered the question posed, just in slightly different ways (although in the end it all comes down to the same formula). Thanks for the implementation on jQuery @Elena Semenchenko! @sitev_ru thanks too! Therefore, I advise those interested to pay attention to all the answers to this question. Thank !

Ar = Ad * пи / 180Where Ad is the angle in degrees, Ar is the angle in radians. - alexoander