-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (58 loc) · 1.64 KB
/
index.html
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/p5@1.11.0/lib/p5.min.js"></script>
<script>
let labels = [0, 5, 10, 100, 500, 1000];
let currentValue = 0;
let maxValue = 1000;
let minValue = 0;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
background(255);
let centerX = width / 2;
let centerY = height * 0.75;
let radius = 150;
let startAngle = -180;
let endAngle = 0;
noFill();
stroke(0);
strokeWeight(4);
arc(centerX, centerY, radius * 2, radius * 2, startAngle, endAngle);
let progressAngle = map(currentValue, minValue, maxValue, startAngle, endAngle);
stroke(0, 255, 0);
strokeWeight(8);
arc(centerX, centerY, radius * 2, radius * 2, startAngle, progressAngle);
strokeWeight(2);
for (let i = 0; i < labels.length; i++) {
let angle = map(i, 0, labels.length - 1, startAngle, endAngle);
let xOuter = centerX + cos(angle) * radius;
let yOuter = centerY + sin(angle) * radius;
let xInner = centerX + cos(angle) * (radius - 15);
let yInner = centerY + sin(angle) * (radius - 15);
line(xOuter, yOuter, xInner, yInner);
let labelX = centerX + cos(angle) * (radius - 35);
let labelY = centerY + sin(angle) * (radius - 35);
textAlign(CENTER, CENTER);
textSize(12);
fill(0);
text(labels[i], labelX, labelY);
}
textAlign(CENTER, CENTER);
textSize(32);
fill(0);
text(currentValue + " Mbps", centerX, centerY - 20);
currentValue += 1;
if (currentValue > maxValue) {
currentValue = 0;
}
}
</script>
<meta charset="utf-8" />
</head>
<body>
</body>
</html>