tangled
alpha
login
or
join now
ptr.pet
/
endpoint
0
fork
atom
data endpoint for entity 90008 (aka. a website)
0
fork
atom
overview
issues
pulls
pipelines
fix nix, small optimization
ptr.pet
2 months ago
f272f518
8e31eb0d
verified
This commit was signed with the committer's
known signature
.
ptr.pet
SSH Key Fingerprint:
SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw=
0/0
Waiting for spindle ...
+13
-26
5 changed files
expand all
collapse all
unified
split
eunomia
src
components
constellationOverlay.svelte
lib
constellation.ts
flake.nix
nix
default.nix
modules.nix
+2
-1
eunomia/src/components/constellationOverlay.svelte
reviewed
···
1
1
<script lang="ts">
2
2
import { genDollcode } from '$lib/dollcode';
3
3
-
import { onMount } from 'svelte';
4
3
5
4
interface Star {
6
5
domain: string;
···
80
79
{#if screenX > -50 && screenX < containerWidth + 50 && screenY > -50 && screenY < containerHeight + 50}
81
80
<a
82
81
href="https://{star.domain}"
82
82
+
target="_blank"
83
83
+
rel="noopener noreferrer"
83
84
class="absolute pointer-events-auto group"
84
85
style="
85
86
left: {screenX - radius}px;
+6
-22
eunomia/src/lib/constellation.ts
reviewed
···
5
5
import { env } from '$env/dynamic/private';
6
6
import type { Canvas } from 'skia-canvas';
7
7
8
8
-
const DATA_DIR = join(env.WEBSITE_DATA_DIR, 'constellation');
8
8
+
const DATA_DIR = join(env.WEBSITE_DATA_DIR ?? '', 'constellation');
9
9
const GRAPH_FILE = join(DATA_DIR, 'graph_processed.json');
10
10
const OUTPUT_FILE = join(DATA_DIR, 'background.svg');
11
11
const DUST_FILE = join(DATA_DIR, 'background_dust.webp');
···
492
492
493
493
// Calculate angle based on time: one full rotation per 3 hours (Y-axis)
494
494
const periodY = 3 * 60 * 60 * 1000;
495
495
-
// Secondary rotation on X-axis to see the poles (slightly different period to avoid repeating patterns)
495
495
+
// Secondary rotation on X-axis to see the poles (different period to avoid repeating patterns)
496
496
const periodX = 5.14 * 60 * 60 * 1000;
497
497
498
498
const date = Date.now();
···
504
504
const cosX = Math.cos(angleX);
505
505
const sinX = Math.sin(angleX);
506
506
507
507
-
// Helper: Apply 3D rotation (Y then X)
508
507
const rotatePoint = (x: number, y: number, z: number) => {
509
508
// Yaw (Y-axis)
510
509
const x1 = x * cosY - z * sinY;
···
519
518
return { x: x2, y: y2, z: z2 };
520
519
};
521
520
522
522
-
// Initialize SVG content
523
521
let svgBody = '';
524
522
let defsContent = '';
525
523
526
526
-
// 0.5 Render Dust via Konva
527
527
-
// Use a Stage/Layer for dust only, transparent background
528
524
const stage = new Konva.Stage({
529
525
width,
530
526
height,
···
663
659
svgBody += `<line x1="${fmt(p1.x)}" y1="${fmt(p1.y)}" x2="${fmt(p2.x)}" y2="${fmt(p2.y)}" stroke="#FFFFFF" stroke-width="${fmt(strokeWidth)}" opacity="${fmt(opacity)}" stroke-linecap="butt" />`;
664
660
}
665
661
662
662
+
// for interactivity (we put links on these screen coordinates)
663
663
+
const visibleStars: { domain: string, x: number, y: number, r: number }[] = [];
666
664
// 3. Draw Stars
667
665
for (const star of stars) {
668
666
if (!projected[star.domain]) continue;
···
680
678
const haloOpacity = opacity * 0.3;
681
679
682
680
svgBody += `<rect x="${fmt(p.x - radius / 2)}" y="${fmt(p.y - radius / 2)}" width="${fmt(radius)}" height="${fmt(radius)}" fill="#EEEEEE" fill-opacity="${fmt(opacity)}" stroke="#FFFFFF" stroke-opacity="${fmt(haloOpacity)}" stroke-width="${fmt(strokeWidth)}" paint-order="stroke fill" />`;
681
681
+
682
682
+
visibleStars.push({ domain: star.domain, x: p.x, y: p.y, r: radius * 1.75 });
683
683
}
684
684
685
685
-
// Construct final SVG
686
685
const finalSvg = `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">
687
686
<defs>${defsContent}</defs>
688
687
${svgBody}
689
688
</svg>`;
690
689
691
690
await writeFile(OUTPUT_FILE, finalSvg);
692
692
-
693
693
-
// Export projected coordinates for frontend interactivity
694
694
-
const visibleStars = stars
695
695
-
.filter(star => projected[star.domain])
696
696
-
.map(star => {
697
697
-
const p = projected[star.domain];
698
698
-
const connectionCount = star.connections ? star.connections.length : 0;
699
699
-
const importance = Math.min(1.5, 1 + connectionCount * 0.1);
700
700
-
return {
701
701
-
domain: star.domain,
702
702
-
x: p.x,
703
703
-
y: p.y,
704
704
-
r: Math.max(1 * RESOLUTION_SCALE, 25 * p.scale * importance) * 0.7
705
705
-
};
706
706
-
});
707
691
708
692
await writeFile(STARS_FILE, JSON.stringify({
709
693
width,
+1
-1
flake.nix
reviewed
···
28
28
];
29
29
shellHook = ''
30
30
export PATH="$PATH:$PWD/node_modules/.bin"
31
31
-
export LD_LIBRARY_PATH="${lib.makeLibraryPath [pkgs.skia]}"
31
31
+
export LD_LIBRARY_PATH="${lib.makeLibraryPath [pkgs.skia pkgs.stdenv.cc.cc.lib]}"
32
32
'';
33
33
};
34
34
packages.eunomia-modules = pkgs.callPackage ./nix/modules.nix {};
+2
nix/default.nix
reviewed
···
3
3
stdenv,
4
4
deno,
5
5
nodejs,
6
6
+
skia,
6
7
makeBinaryWrapper,
7
8
eunomia-modules,
8
9
PUBLIC_BASE_URL ? "http://localhost:5173",
···
50
51
51
52
makeBinaryWrapper ${deno}/bin/deno $out/bin/eunomia \
52
53
--prefix PATH : ${lib.makeBinPath [ deno ]} \
54
54
+
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [skia stdenv.cc.cc.lib]}" \
53
55
--add-flags "run --allow-all --node-modules-dir=manual --cached-only $out/index.js"
54
56
55
57
runHook postInstall
+2
-2
nix/modules.nix
reviewed
···
15
15
];
16
16
};
17
17
18
18
-
outputHash = "sha256-H4aW1XczTjlYwPfPYu0BUcJphSdlfNRZzyrI42shJcY=";
18
18
+
outputHash = "sha256-Q90zpjOn5X6B72g2rIlLhAtaJkLjvJ2yZjRRE4N9DeQ=";
19
19
outputHashAlgo = "sha256";
20
20
outputHashMode = "recursive";
21
21
···
30
30
31
31
'';
32
32
buildPhase = ''
33
33
-
HOME=$TMPDIR deno install --allow-scripts=npm:protobufjs@7.5.4 --frozen --seed 8008135
33
33
+
HOME=$TMPDIR deno install --allow-scripts=npm:protobufjs,npm:sharp,npm:skia-canvas --frozen --seed 8008135
34
34
'';
35
35
installPhase = ''
36
36
cp -R node_modules $out