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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
<!DOCTYPE html>
<html>
<head>
<script src="./analysis.js"></script>
<style>
body {
background-color: #141514;4;4;4;
}
</style>
</head>
<body>
<canvas id="main" width="1000" height="1000" style="border:1px solid #fff;">
</canvas>
<script>
const RADIUS = 20;
const WIDTH = 1000;
const HEIGHT = 1000;
const RING_RADIUS = Math.min(WIDTH, HEIGHT) / 2 - 2 * RADIUS;
const ignore_files = [
"stdbool.h",
"queen.c",
"rook.c",
"king.c",
"pawn.c",
"bishop.c",
"knight.c"
];
data = data.filter(x => !ignore_files.includes(x.name));
const c = document.getElementById("main");
const ctx = c.getContext("2d");
ctx.textAlign = "center";
ctx.font = "bold 10pt Courier";
function canvas_arrow(fromx, fromy, tox, toy) {
var headlen = 10; // length of head in pixels
var dx = tox - fromx;
var dy = toy - fromy;
var angle = Math.atan2(dy, dx);
ctx.moveTo(
fromx + Math.cos(angle) * RADIUS,
fromy + Math.sin(angle) * RADIUS
);
ctx.lineTo(
tox + Math.cos(Math.PI + angle) * RADIUS,
toy + Math.sin(Math.PI + angle) * RADIUS
);
ctx.lineTo(
tox - headlen * Math.cos(angle - Math.PI / 6) + Math.cos(Math.PI + angle) * RADIUS,
toy - headlen * Math.sin(angle - Math.PI / 6) + Math.sin(Math.PI + angle) * RADIUS
);
ctx.moveTo(
tox + Math.cos(Math.PI + angle) * RADIUS,
toy + Math.sin(Math.PI + angle) * RADIUS
);
ctx.lineTo(
tox - headlen * Math.cos(angle + Math.PI / 6) + Math.cos(Math.PI + angle) * RADIUS,
toy - headlen * Math.sin(angle + Math.PI / 6) + Math.sin(Math.PI + angle) * RADIUS
);
}
let mapping = {}
for (let i = 0; i < data.length; i++) {
mapping[data[i].name] = i;
const angle = i * 2 * Math.PI / data.length;
const [x, y] = [
RING_RADIUS * Math.cos(angle) + WIDTH / 2,
RING_RADIUS * Math.sin(angle) + HEIGHT / 2
];
ctx.fillStyle = `hsl(${i * 255 / data.length}, 50%, 50%)`;
ctx.beginPath();
ctx.arc(x, y, RADIUS, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = "white";
ctx.fillText(data[i].name, x, y);
}
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < data[i].imports.length; j++) {
if (!(data[i].imports[j] in mapping)) continue;
const to_idx = mapping[data[i].name];
const from_idx = mapping[data[i].imports[j]];
const from_angle = from_idx * 2 * Math.PI / data.length;
const [from_x, from_y] = [
RING_RADIUS * Math.cos(from_angle) + WIDTH / 2,
RING_RADIUS * Math.sin(from_angle) + HEIGHT / 2
];
const to_angle = to_idx * 2 * Math.PI / data.length;
const [to_x, to_y] = [
RING_RADIUS * Math.cos(to_angle) + WIDTH / 2,
RING_RADIUS * Math.sin(to_angle) + HEIGHT / 2
];
ctx.beginPath();
ctx.strokeStyle = `hsl(${from_idx * 255 / data.length}, 50%, 40%)`;
canvas_arrow(from_x, from_y, to_x, to_y);
ctx.stroke();
}
}
function getCursorPosition(canvas, event) {
const rect = canvas.getBoundingClientRect()
const x = event.clientX - rect.left
const y = event.clientY - rect.top
return [x, y]
}
const canvas = document.querySelector('canvas')
canvas.addEventListener('mousedown', function(e) {
const [x, y] = getCursorPosition(canvas, e)
for (let i = 0; i < data.length; i++) {
const angle = i * 2 * Math.PI / data.length;
const [point_x, point_y] = [
RING_RADIUS * Math.cos(angle) + WIDTH / 2,
RING_RADIUS * Math.sin(angle) + HEIGHT / 2
];
if (Math.pow(point_x - x, 2) + Math.pow(point_y - y, 2) > Math.pow(RADIUS, 2)) {
continue;
}
console.clear()
console.log(data[i].symbols)
console.log(data[i].unused)
console.log(data[i].used)
// for (let j = 0; j < data[i].unused.length; j++) {
// console.log(data[i].unused[j]);
// }
// console.log(data[i].unused.length);
}
})
</script>
</body>
</html>
|