diff options
| author | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-13 21:58:18 +0530 |
|---|---|---|
| committer | Aargh Rai <aargh.rai+git@gmail.com> | 2026-07-13 21:58:18 +0530 |
| commit | f8c0dc54e36cc201c657aa12e5a22029b092e1bc (patch) | |
| tree | a0dd1a42c9681be98a7508c128db0dacacefc2e7 /symbol_analyzer/index.html | |
| parent | 2e8b78ab0ef01eaacd8094ff839ac93b4451e9c3 (diff) | |
restructed all the files + uci done now
also broke the symbol analyser in the process, i didn't help much, i had
to pull out the pen & paper, but it made a cool graph never the less
multithreading was a pain! but it got it in the end
fixed the structs naming convention, if it's used outside by other
files, it's typedeffed, otherwise it's not
fixed the recursive imports issued i had in go_args*, where i was
casting it to void* in uci to make it work
now response.c doesn't deal with ipc, really happy with that change
now every single thing has its own responsibility
Diffstat (limited to 'symbol_analyzer/index.html')
| -rw-r--r-- | symbol_analyzer/index.html | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/symbol_analyzer/index.html b/symbol_analyzer/index.html new file mode 100644 index 0000000..3f0257b --- /dev/null +++ b/symbol_analyzer/index.html @@ -0,0 +1,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> |
