Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +27 -24
templates/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>CELL CLIPPER</title>
|
| 7 |
<style>
|
| 8 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=JetBrains+Mono&display=swap');
|
| 9 |
|
|
@@ -38,7 +38,6 @@
|
|
| 38 |
overflow-y: auto;
|
| 39 |
}
|
| 40 |
|
| 41 |
-
/* Убрали h1, подняли всё вверх */
|
| 42 |
.section { margin-bottom: 30px; }
|
| 43 |
|
| 44 |
.section-title {
|
|
@@ -75,7 +74,6 @@
|
|
| 75 |
}
|
| 76 |
.label-row span:last-child { font-family: var(--font-mono); }
|
| 77 |
|
| 78 |
-
/* Стили для Select */
|
| 79 |
select {
|
| 80 |
width: 100%;
|
| 81 |
padding: 8px;
|
|
@@ -182,9 +180,14 @@
|
|
| 182 |
<div class="section">
|
| 183 |
<span class="section-title">03 / Shape Transformation</span>
|
| 184 |
<div class="control-group">
|
| 185 |
-
<div class="label-row"><span>Base
|
| 186 |
<input type="range" id="base" min="0.1" max="2.0" step="0.05" value="1.0">
|
| 187 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
<div class="control-group">
|
| 190 |
<div class="label-row"><span>Growth Algorithm</span></div>
|
|
@@ -231,6 +234,7 @@
|
|
| 231 |
shift: document.getElementById('shift'),
|
| 232 |
wave: document.getElementById('wave'),
|
| 233 |
base: document.getElementById('base'),
|
|
|
|
| 234 |
growth: document.getElementById('growth'),
|
| 235 |
growth_type: document.getElementById('growth_type')
|
| 236 |
};
|
|
@@ -245,7 +249,7 @@
|
|
| 245 |
const svgEl = xmlDoc.querySelector('svg');
|
| 246 |
if (svgEl) {
|
| 247 |
viewBox = svgEl.getAttribute('viewBox') || `0 0 ${svgEl.getAttribute('width') || 100} ${svgEl.getAttribute('height') || 100}`;
|
| 248 |
-
symbolContent =
|
| 249 |
dropZone.innerText = file.name;
|
| 250 |
update();
|
| 251 |
}
|
|
@@ -269,9 +273,13 @@
|
|
| 269 |
const shiftStagger = getParam('shift');
|
| 270 |
const shiftWave = getParam('wave');
|
| 271 |
const baseScale = getParam('base');
|
|
|
|
| 272 |
const growth = getParam('growth');
|
| 273 |
const growthType = getParam('growth_type');
|
| 274 |
|
|
|
|
|
|
|
|
|
|
| 275 |
const canvasSize = 1000;
|
| 276 |
const step = canvasSize / density;
|
| 277 |
const cellWMax = step * (1.0 - gapX);
|
|
@@ -284,10 +292,9 @@
|
|
| 284 |
let rowWave = Math.sin(r * 0.5) * shiftWave * step;
|
| 285 |
let rowShift = (r * shiftStagger * step) + rowWave;
|
| 286 |
for (let c = 0; c < density; c++) {
|
| 287 |
-
let
|
| 288 |
-
let
|
| 289 |
|
| 290 |
-
// Выбор алгоритма
|
| 291 |
let waveNorm = 0;
|
| 292 |
if (growthType === 'sine') {
|
| 293 |
waveNorm = (Math.sin(c * 0.3 + r * 0.3) + 1) / 2;
|
|
@@ -299,32 +306,28 @@
|
|
| 299 |
}
|
| 300 |
|
| 301 |
let modW = Math.max(0, 1.0 - (waveNorm * growth));
|
| 302 |
-
|
| 303 |
let contentW = cellWMax * baseScale * modW;
|
| 304 |
let contentH = cellHMax * baseScale;
|
| 305 |
-
let contentX = (cellWMax - contentW) / 2;
|
| 306 |
-
let contentY = (cellHMax - contentH) / 2;
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
</g>`;
|
| 313 |
}
|
| 314 |
}
|
| 315 |
|
| 316 |
-
return `<svg id="main-svg" xmlns="http://www.w3.org/2000/svg" width="1000" height="1000" viewBox="0 0 1000 1000">
|
| 317 |
-
<defs>
|
| 318 |
-
<clipPath id="cp"><rect width="${cellWMax.toFixed(2)}" height="${cellHMax.toFixed(2)}" /></clipPath>
|
| 319 |
-
<symbol id="s" viewBox="${viewBox}" preserveAspectRatio="none">${symbolContent}</symbol>
|
| 320 |
-
</defs>
|
| 321 |
-
${body}
|
| 322 |
-
</svg>`;
|
| 323 |
}
|
| 324 |
|
| 325 |
function update() { svgContainer.innerHTML = generateSVG(); }
|
| 326 |
|
| 327 |
-
// Навешиваем обработчики на все контролы
|
| 328 |
Object.values(controls).forEach(input => {
|
| 329 |
input.addEventListener('input', update);
|
| 330 |
if(input.tagName === 'SELECT') input.addEventListener('change', update);
|
|
@@ -335,7 +338,7 @@
|
|
| 335 |
const blob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'});
|
| 336 |
const url = URL.createObjectURL(blob);
|
| 337 |
const link = document.createElement('a');
|
| 338 |
-
link.href = url; link.download = 'cell-clipper-
|
| 339 |
};
|
| 340 |
update();
|
| 341 |
</script>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>CELL CLIPPER / V1.1</title>
|
| 7 |
<style>
|
| 8 |
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=JetBrains+Mono&display=swap');
|
| 9 |
|
|
|
|
| 38 |
overflow-y: auto;
|
| 39 |
}
|
| 40 |
|
|
|
|
| 41 |
.section { margin-bottom: 30px; }
|
| 42 |
|
| 43 |
.section-title {
|
|
|
|
| 74 |
}
|
| 75 |
.label-row span:last-child { font-family: var(--font-mono); }
|
| 76 |
|
|
|
|
| 77 |
select {
|
| 78 |
width: 100%;
|
| 79 |
padding: 8px;
|
|
|
|
| 180 |
<div class="section">
|
| 181 |
<span class="section-title">03 / Shape Transformation</span>
|
| 182 |
<div class="control-group">
|
| 183 |
+
<div class="label-row"><span>Base Scale</span> <span id="val-base">1.0</span></div>
|
| 184 |
<input type="range" id="base" min="0.1" max="2.0" step="0.05" value="1.0">
|
| 185 |
</div>
|
| 186 |
+
|
| 187 |
+
<div class="control-group">
|
| 188 |
+
<div class="label-row"><span>Rotation</span> <span id="val-rotation">0</span></div>
|
| 189 |
+
<input type="range" id="rotation" min="-90" max="90" step="1" value="0">
|
| 190 |
+
</div>
|
| 191 |
|
| 192 |
<div class="control-group">
|
| 193 |
<div class="label-row"><span>Growth Algorithm</span></div>
|
|
|
|
| 234 |
shift: document.getElementById('shift'),
|
| 235 |
wave: document.getElementById('wave'),
|
| 236 |
base: document.getElementById('base'),
|
| 237 |
+
rotation: document.getElementById('rotation'),
|
| 238 |
growth: document.getElementById('growth'),
|
| 239 |
growth_type: document.getElementById('growth_type')
|
| 240 |
};
|
|
|
|
| 249 |
const svgEl = xmlDoc.querySelector('svg');
|
| 250 |
if (svgEl) {
|
| 251 |
viewBox = svgEl.getAttribute('viewBox') || `0 0 ${svgEl.getAttribute('width') || 100} ${svgEl.getAttribute('height') || 100}`;
|
| 252 |
+
symbolContent = svgEl.innerHTML;
|
| 253 |
dropZone.innerText = file.name;
|
| 254 |
update();
|
| 255 |
}
|
|
|
|
| 273 |
const shiftStagger = getParam('shift');
|
| 274 |
const shiftWave = getParam('wave');
|
| 275 |
const baseScale = getParam('base');
|
| 276 |
+
const rotation = getParam('rotation');
|
| 277 |
const growth = getParam('growth');
|
| 278 |
const growthType = getParam('growth_type');
|
| 279 |
|
| 280 |
+
const vb = viewBox.split(' ').map(Number);
|
| 281 |
+
const vW = vb[2], vH = vb[3];
|
| 282 |
+
|
| 283 |
const canvasSize = 1000;
|
| 284 |
const step = canvasSize / density;
|
| 285 |
const cellWMax = step * (1.0 - gapX);
|
|
|
|
| 292 |
let rowWave = Math.sin(r * 0.5) * shiftWave * step;
|
| 293 |
let rowShift = (r * shiftStagger * step) + rowWave;
|
| 294 |
for (let c = 0; c < density; c++) {
|
| 295 |
+
let cx_grid = (c * step + rowShift) % canvasSize;
|
| 296 |
+
let cy_grid = r * step;
|
| 297 |
|
|
|
|
| 298 |
let waveNorm = 0;
|
| 299 |
if (growthType === 'sine') {
|
| 300 |
waveNorm = (Math.sin(c * 0.3 + r * 0.3) + 1) / 2;
|
|
|
|
| 306 |
}
|
| 307 |
|
| 308 |
let modW = Math.max(0, 1.0 - (waveNorm * growth));
|
|
|
|
| 309 |
let contentW = cellWMax * baseScale * modW;
|
| 310 |
let contentH = cellHMax * baseScale;
|
|
|
|
|
|
|
| 311 |
|
| 312 |
+
// Центр ячейки
|
| 313 |
+
let centerX = cx_grid + offsetXBase + cellWMax / 2;
|
| 314 |
+
let centerY = cy_grid + offsetYBase + cellHMax / 2;
|
| 315 |
+
|
| 316 |
+
let sX = (contentW / vW).toFixed(4);
|
| 317 |
+
let sY = (contentH / vH).toFixed(4);
|
| 318 |
+
|
| 319 |
+
// Оптимизированная трансформа для Figma: Translate -> Rotate -> Scale -> Translate back to object origin
|
| 320 |
+
body += `<g transform="translate(${centerX.toFixed(2)} ${centerY.toFixed(2)}) rotate(${rotation}) scale(${sX} ${sY}) translate(${-vW/2} ${-vH/2})">
|
| 321 |
+
${symbolContent}
|
| 322 |
</g>`;
|
| 323 |
}
|
| 324 |
}
|
| 325 |
|
| 326 |
+
return `<svg id="main-svg" xmlns="http://www.w3.org/2000/svg" width="1000" height="1000" viewBox="0 0 1000 1000">${body}</svg>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
}
|
| 328 |
|
| 329 |
function update() { svgContainer.innerHTML = generateSVG(); }
|
| 330 |
|
|
|
|
| 331 |
Object.values(controls).forEach(input => {
|
| 332 |
input.addEventListener('input', update);
|
| 333 |
if(input.tagName === 'SELECT') input.addEventListener('change', update);
|
|
|
|
| 338 |
const blob = new Blob([svgData], {type: 'image/svg+xml;charset=utf-8'});
|
| 339 |
const url = URL.createObjectURL(blob);
|
| 340 |
const link = document.createElement('a');
|
| 341 |
+
link.href = url; link.download = 'cell-clipper-clean.svg'; link.click();
|
| 342 |
};
|
| 343 |
update();
|
| 344 |
</script>
|