Spaces:
Running
Running
Update index.html
Browse files- index.html +25 -9
index.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<html lang="zh-CN">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<title>BeadMaster Pro v10.
|
| 6 |
<style>
|
| 7 |
:root { --bg: #18181b; --panel: #27272a; --accent: #8b5cf6; --success: #10b981; --warn: #f59e0b; --text: #f4f4f5; --border: #3f3f46; --ruler-bg: #202022; }
|
| 8 |
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: 'Segoe UI', Roboto, sans-serif; user-select: none; }
|
|
@@ -91,7 +91,7 @@
|
|
| 91 |
|
| 92 |
<div id="app">
|
| 93 |
<div class="sidebar">
|
| 94 |
-
<div style="height: 56px; display: flex; align-items: center; font-weight: 900; color: var(--accent); font-size: 14px;">v10.
|
| 95 |
<button class="tool-btn active" id="t-pencil" onclick="setTool('pencil')" title="画笔">✏️</button>
|
| 96 |
<button class="tool-btn" id="t-eraser" onclick="setTool('eraser')" title="橡皮">🧼</button>
|
| 97 |
<button class="tool-btn" id="t-bucket" onclick="setTool('bucket')" title="油漆桶">🪣</button>
|
|
@@ -389,14 +389,14 @@ function copyList() {
|
|
| 389 |
|
| 390 |
function draw() {
|
| 391 |
const s = state.scale; const ox = state.offsetX; const oy = state.offsetY;
|
| 392 |
-
const shape = document.getElementById('shapeSelect').value;
|
| 393 |
|
| 394 |
ctx.fillStyle = '#09090b'; ctx.fillRect(0, 0, cvs.width, cvs.height);
|
| 395 |
ctx.save(); ctx.translate(ox, oy);
|
| 396 |
|
| 397 |
if (state.mode === '3d') {
|
| 398 |
const offsetPerLayer = s * 0.15;
|
| 399 |
-
const explodeY = state.explodeVal * (s * 0.05);
|
| 400 |
const singleMode = document.getElementById('singleLayerCheck').checked;
|
| 401 |
|
| 402 |
ctx.strokeStyle = '#333'; ctx.lineWidth = 1; ctx.beginPath();
|
|
@@ -528,6 +528,9 @@ function exportSlices() {
|
|
| 528 |
const layers = state.maxLayers; const unit = 20; const w = state.gridW * unit; const h = state.gridH * unit; const margin = 40;
|
| 529 |
const expCv = document.createElement('canvas'); expCv.width = w + margin*2; expCv.height = (h + margin) * layers + margin;
|
| 530 |
const ctx = expCv.getContext('2d'); ctx.fillStyle = 'white'; ctx.fillRect(0,0,expCv.width, expCv.height);
|
|
|
|
|
|
|
|
|
|
| 531 |
for(let l=1; l<=layers; l++) {
|
| 532 |
const startY = (l-1)*(h+margin) + margin;
|
| 533 |
ctx.fillStyle = '#000'; ctx.font = '20px Arial'; ctx.textAlign = 'left'; ctx.fillText(`第 ${l} 层 (Layer ${l})`, margin, startY - 10);
|
|
@@ -536,8 +539,13 @@ function exportSlices() {
|
|
| 536 |
const hVal = state.heightMap[key] || 1;
|
| 537 |
if(hVal >= l) {
|
| 538 |
const [x, y] = key.split(',').map(Number); const p = PALETTE[state.pixels[key]];
|
| 539 |
-
ctx.fillStyle = p.hex;
|
| 540 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
}
|
| 542 |
}
|
| 543 |
ctx.strokeStyle = '#ddd'; ctx.lineWidth=1;
|
|
@@ -551,13 +559,21 @@ function exportImageWithRuler() {
|
|
| 551 |
const expCvs = document.createElement('canvas'); expCvs.width = state.gridW * unit + margin; expCvs.height = state.gridH * unit + margin;
|
| 552 |
const eCtx = expCvs.getContext('2d'); eCtx.fillStyle = 'white'; eCtx.fillRect(0, 0, expCvs.width, expCvs.height);
|
| 553 |
eCtx.fillStyle = '#000'; eCtx.font = `bold ${unit*0.8}px Arial`; eCtx.textAlign = 'center'; eCtx.textBaseline = 'middle';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 554 |
for(let i=0; i<=state.gridW; i++) { if(i%5===0) { const x = margin + i*unit; eCtx.fillText(i, x, margin/2); eCtx.fillRect(x, margin-unit, 4, unit); } }
|
| 555 |
for(let i=0; i<=state.gridH; i++) { if(i%5===0) { const y = margin + i*unit; eCtx.fillText(i, margin/2, y); eCtx.fillRect(margin-unit, y, unit, 4); } }
|
| 556 |
eCtx.translate(margin, margin);
|
| 557 |
for(let key in state.pixels) {
|
| 558 |
const [x, y] = key.split(',').map(Number); const p = PALETTE[state.pixels[key]]; eCtx.fillStyle = p.hex;
|
| 559 |
-
|
| 560 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
eCtx.fillStyle = getContrastColor(p.hex) === '#fff' ? '#fff' : '#000'; eCtx.font = `bold ${unit*0.35}px Arial`; eCtx.fillText(p.id, x*unit + unit/2, y*unit + unit/2);
|
| 562 |
}
|
| 563 |
eCtx.strokeStyle = '#999'; eCtx.lineWidth = 3; for(let i=0; i<=state.gridW; i++) { eCtx.moveTo(i*unit, 0); eCtx.lineTo(i*unit, state.gridH*unit); } for(let i=0; i<=state.gridH; i++) { eCtx.moveTo(0, i*unit); eCtx.lineTo(state.gridW*unit, i*unit); } eCtx.stroke();
|
|
@@ -627,8 +643,8 @@ function floodFill(x, y, targetIdx) {
|
|
| 627 |
}
|
| 628 |
function setTool(t) { state.tool = t; document.querySelectorAll('.tool-btn').forEach(b => b.classList.remove('active')); document.getElementById(`t-${t}`).classList.add('active'); viewport.style.cursor = t==='move' ? 'grab' : 'crosshair'; }
|
| 629 |
function resizeGrid() { state.gridW = parseInt(document.getElementById('gridW').value) || 60; state.gridH = parseInt(document.getElementById('gridH').value) || 60; draw(); }
|
| 630 |
-
function updateInfo(e) { document.getElementById('info-zoom').innerText = `Zoom: ${state.scale}px`; if(e) { const rect = viewport.getBoundingClientRect(); const x = Math.floor((e.clientX - rect.left - state.offsetX) / state.scale); const y = Math.floor((e.clientY - rect.top - state.offsetY) / state.scale); if(x>=0 && x<state.gridW && y>=0 && y<state.gridH) document.getElementById('info-coord').innerText = `XY: (${x}, ${y})`; } }
|
| 631 |
function clearCanvas() { if(confirm('确定清空画布吗?')) { state.pixels={}; draw(); } }
|
|
|
|
| 632 |
|
| 633 |
init();
|
| 634 |
</script>
|
|
|
|
| 2 |
<html lang="zh-CN">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>BeadMaster Pro v10.3 - 完美修正版</title>
|
| 6 |
<style>
|
| 7 |
:root { --bg: #18181b; --panel: #27272a; --accent: #8b5cf6; --success: #10b981; --warn: #f59e0b; --text: #f4f4f5; --border: #3f3f46; --ruler-bg: #202022; }
|
| 8 |
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: 'Segoe UI', Roboto, sans-serif; user-select: none; }
|
|
|
|
| 91 |
|
| 92 |
<div id="app">
|
| 93 |
<div class="sidebar">
|
| 94 |
+
<div style="height: 56px; display: flex; align-items: center; font-weight: 900; color: var(--accent); font-size: 14px;">v10.3</div>
|
| 95 |
<button class="tool-btn active" id="t-pencil" onclick="setTool('pencil')" title="画笔">✏️</button>
|
| 96 |
<button class="tool-btn" id="t-eraser" onclick="setTool('eraser')" title="橡皮">🧼</button>
|
| 97 |
<button class="tool-btn" id="t-bucket" onclick="setTool('bucket')" title="油漆桶">🪣</button>
|
|
|
|
| 389 |
|
| 390 |
function draw() {
|
| 391 |
const s = state.scale; const ox = state.offsetX; const oy = state.offsetY;
|
| 392 |
+
const shape = document.getElementById('shapeSelect').value; // 实时获取形状
|
| 393 |
|
| 394 |
ctx.fillStyle = '#09090b'; ctx.fillRect(0, 0, cvs.width, cvs.height);
|
| 395 |
ctx.save(); ctx.translate(ox, oy);
|
| 396 |
|
| 397 |
if (state.mode === '3d') {
|
| 398 |
const offsetPerLayer = s * 0.15;
|
| 399 |
+
const explodeY = state.explodeVal * (s * 0.05);
|
| 400 |
const singleMode = document.getElementById('singleLayerCheck').checked;
|
| 401 |
|
| 402 |
ctx.strokeStyle = '#333'; ctx.lineWidth = 1; ctx.beginPath();
|
|
|
|
| 528 |
const layers = state.maxLayers; const unit = 20; const w = state.gridW * unit; const h = state.gridH * unit; const margin = 40;
|
| 529 |
const expCv = document.createElement('canvas'); expCv.width = w + margin*2; expCv.height = (h + margin) * layers + margin;
|
| 530 |
const ctx = expCv.getContext('2d'); ctx.fillStyle = 'white'; ctx.fillRect(0,0,expCv.width, expCv.height);
|
| 531 |
+
// V10.3 修正:同步导出形状
|
| 532 |
+
const shape = document.getElementById('shapeSelect').value;
|
| 533 |
+
|
| 534 |
for(let l=1; l<=layers; l++) {
|
| 535 |
const startY = (l-1)*(h+margin) + margin;
|
| 536 |
ctx.fillStyle = '#000'; ctx.font = '20px Arial'; ctx.textAlign = 'left'; ctx.fillText(`第 ${l} 层 (Layer ${l})`, margin, startY - 10);
|
|
|
|
| 539 |
const hVal = state.heightMap[key] || 1;
|
| 540 |
if(hVal >= l) {
|
| 541 |
const [x, y] = key.split(',').map(Number); const p = PALETTE[state.pixels[key]];
|
| 542 |
+
ctx.fillStyle = p.hex;
|
| 543 |
+
if (shape === 'circle') {
|
| 544 |
+
ctx.beginPath(); ctx.arc(x*unit + unit/2, y*unit + unit/2, unit/2 - 1, 0, Math.PI*2); ctx.fill();
|
| 545 |
+
ctx.fillStyle = '#fff'; ctx.beginPath(); ctx.arc(x*unit + unit/2, y*unit + unit/2, unit/6, 0, Math.PI*2); ctx.fill();
|
| 546 |
+
} else {
|
| 547 |
+
ctx.fillRect(x*unit, y*unit, unit, unit);
|
| 548 |
+
}
|
| 549 |
}
|
| 550 |
}
|
| 551 |
ctx.strokeStyle = '#ddd'; ctx.lineWidth=1;
|
|
|
|
| 559 |
const expCvs = document.createElement('canvas'); expCvs.width = state.gridW * unit + margin; expCvs.height = state.gridH * unit + margin;
|
| 560 |
const eCtx = expCvs.getContext('2d'); eCtx.fillStyle = 'white'; eCtx.fillRect(0, 0, expCvs.width, expCvs.height);
|
| 561 |
eCtx.fillStyle = '#000'; eCtx.font = `bold ${unit*0.8}px Arial`; eCtx.textAlign = 'center'; eCtx.textBaseline = 'middle';
|
| 562 |
+
|
| 563 |
+
// V10.3 修正:同步导出形状
|
| 564 |
+
const shape = document.getElementById('shapeSelect').value;
|
| 565 |
+
|
| 566 |
for(let i=0; i<=state.gridW; i++) { if(i%5===0) { const x = margin + i*unit; eCtx.fillText(i, x, margin/2); eCtx.fillRect(x, margin-unit, 4, unit); } }
|
| 567 |
for(let i=0; i<=state.gridH; i++) { if(i%5===0) { const y = margin + i*unit; eCtx.fillText(i, margin/2, y); eCtx.fillRect(margin-unit, y, unit, 4); } }
|
| 568 |
eCtx.translate(margin, margin);
|
| 569 |
for(let key in state.pixels) {
|
| 570 |
const [x, y] = key.split(',').map(Number); const p = PALETTE[state.pixels[key]]; eCtx.fillStyle = p.hex;
|
| 571 |
+
if (shape === 'circle') {
|
| 572 |
+
eCtx.beginPath(); eCtx.arc(x*unit + unit/2, y*unit + unit/2, unit/2 - unit*0.05, 0, Math.PI*2); eCtx.fill();
|
| 573 |
+
eCtx.fillStyle = '#fff'; eCtx.beginPath(); eCtx.arc(x*unit + unit/2, y*unit + unit/2, unit*0.15, 0, Math.PI*2); eCtx.fill();
|
| 574 |
+
} else {
|
| 575 |
+
eCtx.fillRect(x*unit, y*unit, unit, unit);
|
| 576 |
+
}
|
| 577 |
eCtx.fillStyle = getContrastColor(p.hex) === '#fff' ? '#fff' : '#000'; eCtx.font = `bold ${unit*0.35}px Arial`; eCtx.fillText(p.id, x*unit + unit/2, y*unit + unit/2);
|
| 578 |
}
|
| 579 |
eCtx.strokeStyle = '#999'; eCtx.lineWidth = 3; for(let i=0; i<=state.gridW; i++) { eCtx.moveTo(i*unit, 0); eCtx.lineTo(i*unit, state.gridH*unit); } for(let i=0; i<=state.gridH; i++) { eCtx.moveTo(0, i*unit); eCtx.lineTo(state.gridW*unit, i*unit); } eCtx.stroke();
|
|
|
|
| 643 |
}
|
| 644 |
function setTool(t) { state.tool = t; document.querySelectorAll('.tool-btn').forEach(b => b.classList.remove('active')); document.getElementById(`t-${t}`).classList.add('active'); viewport.style.cursor = t==='move' ? 'grab' : 'crosshair'; }
|
| 645 |
function resizeGrid() { state.gridW = parseInt(document.getElementById('gridW').value) || 60; state.gridH = parseInt(document.getElementById('gridH').value) || 60; draw(); }
|
|
|
|
| 646 |
function clearCanvas() { if(confirm('确定清空画布吗?')) { state.pixels={}; draw(); } }
|
| 647 |
+
function updateInfo(e) { document.getElementById('info-zoom').innerText = `Zoom: ${state.scale}px`; if(e) { const rect = viewport.getBoundingClientRect(); const x = Math.floor((e.clientX - rect.left - state.offsetX) / state.scale); const y = Math.floor((e.clientY - rect.top - state.offsetY) / state.scale); if(x>=0 && x<state.gridW && y>=0 && y<state.gridH) document.getElementById('info-coord').innerText = `XY: (${x}, ${y})`; } }
|
| 648 |
|
| 649 |
init();
|
| 650 |
</script>
|