-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
50 lines (33 loc) · 1.1 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function drawCircle(value) {
var text = "||||||||||||";
if (value && value != "") {
text = value;
}
const word = text.split("");
const quantity = word.length;
const radius = 150;
const padding = 300;
const radians = 3.1415; // Max radians value (full circle)
const angle = 360 / (2 * Math.PI); //angle to radian relation
const point = Math.PI / quantity;
const step = (2 * Math.PI) / quantity;
const elm_arr = [];
for (let i = 0, j = 0; i < radians; i += point, j++) {
const cat_oppos = Math.sin(step * j) * radius;
const cat_attach = Math.cos(step * j) * radius;
const elm = document.createElement("div");
elm.innerHTML = word[j];
elm.classList.add("dot");
elm.style.top = padding + cat_oppos + "px";
elm.style.left = padding + cat_attach + "px";
elm.style.transform = "rotate(" + (angle * (step * j) + 90) + "deg)";
elm_arr.push(elm);
}
const elm = document.createElement("div");
elm.innerHTML = "|";
elm.classList.add("dot");
elm.style.top = padding + "px";
elm.style.left = padding + "px";
elm_arr.push(elm);
return elm_arr;
}