Spaces:
Running
Running
thibaud frere
commited on
Commit
·
67fcbc2
1
Parent(s):
33aefb9
update
Browse files
app/src/content/embeds/color-picker.html
CHANGED
|
@@ -146,7 +146,7 @@
|
|
| 146 |
const rgb = base.rgb().map(v => Math.round(v));
|
| 147 |
currentRgb.textContent = `RGB ${rgb[0]}, ${rgb[1]}, ${rgb[2]}`;
|
| 148 |
}
|
| 149 |
-
//
|
| 150 |
const hoverL = Math.max(0, Math.min(100, L - 8));
|
| 151 |
const hoverHex = chroma.lch(hoverL, C, h).hex();
|
| 152 |
const rootEl = document.documentElement;
|
|
@@ -171,7 +171,7 @@
|
|
| 171 |
updateUI(hue, adjusting);
|
| 172 |
});
|
| 173 |
|
| 174 |
-
// Init
|
| 175 |
try {
|
| 176 |
const cssPrimary = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim();
|
| 177 |
if (cssPrimary) {
|
|
@@ -203,7 +203,7 @@
|
|
| 203 |
if (slider) {
|
| 204 |
slider.addEventListener('mousedown', onDown);
|
| 205 |
slider.addEventListener('touchstart', onDown, { passive: false });
|
| 206 |
-
// Minimal support
|
| 207 |
slider.addEventListener('keydown', (e) => {
|
| 208 |
const step = e.shiftKey ? 10 : 2;
|
| 209 |
if (e.key === 'ArrowLeft') { e.preventDefault(); const { hue } = bus.get(); const h = hue - step; updateUI(h, true); bus.publish(instanceId, h, true); bus.publish(instanceId, h, false); }
|
|
|
|
| 146 |
const rgb = base.rgb().map(v => Math.round(v));
|
| 147 |
currentRgb.textContent = `RGB ${rgb[0]}, ${rgb[1]}, ${rgb[2]}`;
|
| 148 |
}
|
| 149 |
+
// Apply to theme (always, to reflect the selection)
|
| 150 |
const hoverL = Math.max(0, Math.min(100, L - 8));
|
| 151 |
const hoverHex = chroma.lch(hoverL, C, h).hex();
|
| 152 |
const rootEl = document.documentElement;
|
|
|
|
| 171 |
updateUI(hue, adjusting);
|
| 172 |
});
|
| 173 |
|
| 174 |
+
// Init from theme color if available
|
| 175 |
try {
|
| 176 |
const cssPrimary = getComputedStyle(document.documentElement).getPropertyValue('--primary-color').trim();
|
| 177 |
if (cssPrimary) {
|
|
|
|
| 203 |
if (slider) {
|
| 204 |
slider.addEventListener('mousedown', onDown);
|
| 205 |
slider.addEventListener('touchstart', onDown, { passive: false });
|
| 206 |
+
// Minimal keyboard support (←/→, Shift for larger steps)
|
| 207 |
slider.addEventListener('keydown', (e) => {
|
| 208 |
const step = e.shiftKey ? 10 : 2;
|
| 209 |
if (e.key === 'ArrowLeft') { e.preventDefault(); const { hue } = bus.get(); const h = hue - step; updateUI(h, true); bus.publish(instanceId, h, true); bus.publish(instanceId, h, false); }
|
app/src/content/embeds/d3-pie.html
CHANGED
|
@@ -78,8 +78,8 @@
|
|
| 78 |
|
| 79 |
// Layout
|
| 80 |
let width=800, height=450; const margin = { top: 0, right: 24, bottom: 32, left: 24 };
|
| 81 |
-
const CAPTION_GAP = 28; //
|
| 82 |
-
const LEGEND_GAP = 8; //
|
| 83 |
const updateSize = () => {
|
| 84 |
width = container.clientWidth || 800;
|
| 85 |
height = Math.max(260, Math.round(width/3.4));
|
|
@@ -127,7 +127,7 @@
|
|
| 127 |
const cellWidth = (pieAreaWidth - gapX * (cols - 1)) / cols;
|
| 128 |
const cellHeight = innerHeight - 6; // room for captions
|
| 129 |
const radius = Math.max(30, Math.min(cellWidth, cellHeight) * 0.42);
|
| 130 |
-
const innerR = Math.round(radius * 0.28); // donut,
|
| 131 |
|
| 132 |
const pie = d3.pie().sort(null).value(d => d.value).padAngle(0.02);
|
| 133 |
const arc = d3.arc().innerRadius(innerR).outerRadius(radius).cornerRadius(3);
|
|
|
|
| 78 |
|
| 79 |
// Layout
|
| 80 |
let width=800, height=450; const margin = { top: 0, right: 24, bottom: 32, left: 24 };
|
| 81 |
+
const CAPTION_GAP = 28; // gap between title and donut (larger)
|
| 82 |
+
const LEGEND_GAP = 8; // gap between donut and legend (smaller)
|
| 83 |
const updateSize = () => {
|
| 84 |
width = container.clientWidth || 800;
|
| 85 |
height = Math.max(260, Math.round(width/3.4));
|
|
|
|
| 127 |
const cellWidth = (pieAreaWidth - gapX * (cols - 1)) / cols;
|
| 128 |
const cellHeight = innerHeight - 6; // room for captions
|
| 129 |
const radius = Math.max(30, Math.min(cellWidth, cellHeight) * 0.42);
|
| 130 |
+
const innerR = Math.round(radius * 0.28); // donut, moderate hole
|
| 131 |
|
| 132 |
const pie = d3.pie().sort(null).value(d => d.value).padAngle(0.02);
|
| 133 |
const arc = d3.arc().innerRadius(innerR).outerRadius(radius).cornerRadius(3);
|
app/src/content/embeds/heatmap.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
<div class="d3-train-diagram" style="width:100%;margin:10px 0;"></div>
|
| 2 |
-
<div class="caption">
|
| 3 |
<style>
|
| 4 |
.d3-train-diagram + .caption { margin-top: 8px; font-size: 14px; color: var(--muted-color); }
|
| 5 |
</style>
|
|
@@ -31,12 +31,12 @@
|
|
| 31 |
{ key: 'updated', label: 'Updated', color: '#7c3aed' },
|
| 32 |
];
|
| 33 |
const hoverText = {
|
| 34 |
-
model: '
|
| 35 |
-
forward: '
|
| 36 |
-
backward: '
|
| 37 |
-
gradients: '
|
| 38 |
-
optimization: '
|
| 39 |
-
updated: '
|
| 40 |
};
|
| 41 |
|
| 42 |
// SVG
|
|
|
|
| 1 |
<div class="d3-train-diagram" style="width:100%;margin:10px 0;"></div>
|
| 2 |
+
<div class="caption">Hover blocks to show an explanation.</div>
|
| 3 |
<style>
|
| 4 |
.d3-train-diagram + .caption { margin-top: 8px; font-size: 14px; color: var(--muted-color); }
|
| 5 |
</style>
|
|
|
|
| 31 |
{ key: 'updated', label: 'Updated', color: '#7c3aed' },
|
| 32 |
];
|
| 33 |
const hoverText = {
|
| 34 |
+
model: 'Each block represents a submodule of the model.',
|
| 35 |
+
forward: 'Forward pass: compute activations layer by layer.',
|
| 36 |
+
backward: 'Backpropagation: compute gradients through the chain.',
|
| 37 |
+
gradients: 'Gradient accumulators for each layer.',
|
| 38 |
+
optimization: 'Optimization step: update the weights.',
|
| 39 |
+
updated: 'Parameters updated, ready for the next iteration.'
|
| 40 |
};
|
| 41 |
|
| 42 |
// SVG
|
app/src/content/embeds/palettes.html
CHANGED
|
@@ -115,7 +115,7 @@
|
|
| 115 |
const baseH = base.get('hsl.h') || 0;
|
| 116 |
const L0 = Math.max(40, Math.min(85, lc[0] || 70));
|
| 117 |
const C0 = Math.max(45, Math.min(75, lc[1] || 70));
|
| 118 |
-
const MIN_DELTA = 18; // distance
|
| 119 |
|
| 120 |
const seen = new Set();
|
| 121 |
const results = [];
|
|
@@ -138,7 +138,7 @@
|
|
| 138 |
if (!seen.has(hex.toLowerCase())) { results.push(hex); seen.add(hex.toLowerCase()); }
|
| 139 |
};
|
| 140 |
|
| 141 |
-
// Base
|
| 142 |
pushHex(base);
|
| 143 |
|
| 144 |
const total = Math.max(6, Math.min(10, count || 6));
|
|
@@ -161,7 +161,7 @@
|
|
| 161 |
}
|
| 162 |
}
|
| 163 |
if (!accepted) {
|
| 164 |
-
//
|
| 165 |
let cTry = C0 - 10;
|
| 166 |
let trials = 0;
|
| 167 |
while (!accepted && cTry >= 30 && trials < 6) {
|
|
|
|
| 115 |
const baseH = base.get('hsl.h') || 0;
|
| 116 |
const L0 = Math.max(40, Math.min(85, lc[0] || 70));
|
| 117 |
const C0 = Math.max(45, Math.min(75, lc[1] || 70));
|
| 118 |
+
const MIN_DELTA = 18; // minimal distance in Lab
|
| 119 |
|
| 120 |
const seen = new Set();
|
| 121 |
const results = [];
|
|
|
|
| 138 |
if (!seen.has(hex.toLowerCase())) { results.push(hex); seen.add(hex.toLowerCase()); }
|
| 139 |
};
|
| 140 |
|
| 141 |
+
// Base first
|
| 142 |
pushHex(base);
|
| 143 |
|
| 144 |
const total = Math.max(6, Math.min(10, count || 6));
|
|
|
|
| 161 |
}
|
| 162 |
}
|
| 163 |
if (!accepted) {
|
| 164 |
+
// Reduce chroma if necessary
|
| 165 |
let cTry = C0 - 10;
|
| 166 |
let trials = 0;
|
| 167 |
while (!accepted && cTry >= 30 && trials < 6) {
|