|
26 | 26 | let scrollFrame = 0; |
27 | 27 | const palette = { |
28 | 28 | paper: "rgb(252 252 251)", |
| 29 | + surface: "rgb(252 252 251)", |
| 30 | + surfaceSubtle: "rgb(247 248 249)", |
29 | 31 | ink: "rgb(25 27 31)", |
| 32 | + soft: "rgb(68 73 80)", |
30 | 33 | muted: "rgb(111 116 124)", |
31 | 34 | line: "rgb(204 208 213)", |
32 | 35 | lineSoft: "rgb(226 229 232)", |
33 | 36 | accent: "rgb(42 104 143)", |
34 | 37 | particle: "rgb(25 27 31 / 0.88)", |
| 38 | + particleIntro: "rgb(25 27 31 / 0.88)", |
35 | 39 | replica: "rgb(81 87 95 / 0.62)" |
36 | 40 | }; |
37 | 41 |
|
38 | 42 | function syncPalette() { |
39 | 43 | const styles = getComputedStyle(document.documentElement); |
40 | 44 | const dark = styles.colorScheme === "dark"; |
41 | 45 | palette.paper = styles.getPropertyValue("--color-surface").trim() || palette.paper; |
| 46 | + palette.surface = styles.getPropertyValue("--color-surface").trim() || palette.surface; |
| 47 | + palette.surfaceSubtle = |
| 48 | + styles.getPropertyValue("--color-surface-subtle").trim() || palette.surfaceSubtle; |
42 | 49 | palette.ink = styles.getPropertyValue("--color-text").trim() || palette.ink; |
| 50 | + palette.soft = styles.getPropertyValue("--color-text-soft").trim() || palette.soft; |
43 | 51 | palette.muted = styles.getPropertyValue("--color-text-muted").trim() || palette.muted; |
44 | | - palette.line = styles.getPropertyValue("--color-border-strong").trim() || palette.line; |
| 52 | + palette.line = dark |
| 53 | + ? styles.getPropertyValue("--color-text-faint").trim() || palette.muted |
| 54 | + : styles.getPropertyValue("--color-text-muted").trim() || palette.muted; |
45 | 55 | palette.lineSoft = styles.getPropertyValue("--color-border").trim() || palette.lineSoft; |
46 | 56 | palette.accent = styles.getPropertyValue("--color-accent").trim() || palette.accent; |
47 | 57 | palette.particle = dark |
48 | | - ? styles.getPropertyValue("--color-text-soft").trim() || palette.ink |
49 | | - : "rgb(25 27 31 / 0.88)"; |
50 | | - palette.replica = dark |
51 | 58 | ? styles.getPropertyValue("--color-text-muted").trim() || palette.muted |
52 | | - : "rgb(81 87 95 / 0.62)"; |
| 59 | + : styles.getPropertyValue("--color-text").trim() || palette.ink; |
| 60 | + palette.particleIntro = dark |
| 61 | + ? styles.getPropertyValue("--color-text-soft").trim() || palette.soft |
| 62 | + : styles.getPropertyValue("--color-text").trim() || palette.ink; |
| 63 | + palette.replica = |
| 64 | + styles.getPropertyValue("--color-text-muted").trim() || palette.muted; |
53 | 65 | } |
54 | 66 |
|
55 | 67 | class Particle { |
|
842 | 854 | if (!points || points.length < 2) return; |
843 | 855 |
|
844 | 856 | context.save(); |
845 | | - context.strokeStyle = "rgb(113 120 129 / 0.48)"; |
| 857 | + context.strokeStyle = palette.muted; |
| 858 | + context.globalAlpha = 0.88; |
846 | 859 | context.lineWidth = 1; |
847 | 860 | context.setLineDash(edge.dashed ? [4, 5] : []); |
848 | 861 | context.beginPath(); |
|
854 | 867 | const finalPoint = points[points.length - 1]; |
855 | 868 | const previousPoint = points[points.length - 2]; |
856 | 869 | const angle = Math.atan2(finalPoint.y - previousPoint.y, finalPoint.x - previousPoint.x); |
857 | | - context.fillStyle = "rgb(113 120 129 / 0.62)"; |
| 870 | + context.fillStyle = palette.muted; |
| 871 | + context.globalAlpha = 0.95; |
858 | 872 | context.beginPath(); |
859 | 873 | context.moveTo(finalPoint.x, finalPoint.y); |
860 | 874 | context.lineTo( |
|
882 | 896 | context.font = |
883 | 897 | `${compact ? 8 : 9}px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`; |
884 | 898 | const metrics = context.measureText(edge.label); |
885 | | - context.fillStyle = "rgb(252 252 251 / 0.96)"; |
| 899 | + context.fillStyle = palette.surface; |
886 | 900 | context.fillRect(x - metrics.width / 2 - 4, y - 7, metrics.width + 8, 12); |
887 | 901 | context.fillStyle = palette.muted; |
888 | 902 | context.textAlign = "center"; |
|
895 | 909 | context.save(); |
896 | 910 |
|
897 | 911 | if (node.kind === "boundary") { |
898 | | - context.fillStyle = "rgb(252 252 251 / 0.42)"; |
899 | | - context.strokeStyle = "rgb(126 133 142 / 0.48)"; |
| 912 | + context.fillStyle = palette.surface; |
| 913 | + context.strokeStyle = palette.line; |
900 | 914 | context.setLineDash([5, 5]); |
| 915 | + } else if (node.kind === "authority") { |
| 916 | + context.fillStyle = palette.surfaceSubtle; |
| 917 | + context.strokeStyle = palette.accent; |
| 918 | + context.setLineDash([]); |
901 | 919 | } else { |
902 | 920 | context.fillStyle = |
903 | | - node.kind === "authority" |
904 | | - ? "rgb(247 250 251 / 0.94)" |
905 | | - : "rgb(252 252 251 / 0.90)"; |
| 921 | + node.kind === "service" ? palette.surfaceSubtle : palette.surface; |
906 | 922 | context.strokeStyle = |
907 | | - node.kind === "authority" |
908 | | - ? "rgb(42 104 143 / 0.62)" |
909 | | - : "rgb(152 158 166 / 0.56)"; |
| 923 | + node.kind === "replica" ? palette.muted : palette.line; |
910 | 924 | context.setLineDash(node.kind === "replica" ? [4, 4] : []); |
911 | 925 | } |
912 | 926 |
|
|
950 | 964 | context.restore(); |
951 | 965 | } |
952 | 966 |
|
| 967 | + function particleFill(particle) { |
| 968 | + if (particle.role === "packet" || particle.role === "metadata") { |
| 969 | + return palette.accent; |
| 970 | + } |
| 971 | + if (activeScene === "intro") { |
| 972 | + return particle.index % 17 === 0 |
| 973 | + ? palette.accent |
| 974 | + : palette.particleIntro; |
| 975 | + } |
| 976 | + if (activeScene === "modes" && particle.index >= 181) { |
| 977 | + return palette.accent; |
| 978 | + } |
| 979 | + if ( |
| 980 | + activeScene === "access" |
| 981 | + && particle.index >= 151 |
| 982 | + && particle.index < 301 |
| 983 | + ) { |
| 984 | + return palette.accent; |
| 985 | + } |
| 986 | + return palette.particle; |
| 987 | + } |
| 988 | + |
953 | 989 | function drawParticle(particle, compact) { |
954 | | - const baseSize = compact ? 2.25 : 3.25; |
| 990 | + const baseSize = compact ? 2.5 : 3.25; |
955 | 991 | const size = |
956 | 992 | particle.role === "packet" |
957 | 993 | ? baseSize * 1.5 |
|
961 | 997 |
|
962 | 998 | if (particle.role === "replica") { |
963 | 999 | context.strokeStyle = palette.replica; |
964 | | - context.lineWidth = 0.8; |
965 | | - context.strokeRect(x, y, Math.max(1.5, size), Math.max(1.5, size)); |
| 1000 | + context.lineWidth = 0.9; |
| 1001 | + context.strokeRect(x, y, Math.max(1.75, size), Math.max(1.75, size)); |
966 | 1002 | } else { |
967 | | - context.fillStyle = |
968 | | - particle.role === "packet" || particle.role === "metadata" |
969 | | - ? palette.accent |
970 | | - : palette.particle; |
971 | | - context.fillRect(x, y, Math.max(1.5, size), Math.max(1.5, size)); |
| 1003 | + context.fillStyle = particleFill(particle); |
| 1004 | + context.fillRect(x, y, Math.max(1.75, size), Math.max(1.75, size)); |
972 | 1005 | } |
973 | 1006 | } |
974 | 1007 |
|
|
0 commit comments