big update

This commit is contained in:
2026-11-18 15:18:38 +01:00
parent e0496fa089
commit 64c5b65543
39 changed files with 1938 additions and 367 deletions

View File

@@ -29,7 +29,7 @@
let tool = 'brush', color = '#ffffff', size = 14, stamp = '★', text = '', mirror = true;
let undo = [], drawing = null, panel = null, before = null, pending = false;
function build() {
function build(host) {
panel = document.createElement('div');
panel.id = 'painter';
panel.innerHTML = `
@@ -45,7 +45,7 @@
<div class="pt-colors" id="ptColors">${COLORS.map(c => `<span class="sw" data-c="${c}" style="background:${c}"></span>`).join('')}<input type="color" id="ptPick" value="${color}"></div>
<div class="gbar"><button id="ptUndo">↶ ${t('pt_undo')}</button><button id="ptClear">${t('pt_clear')}</button><div class="grow"></div>
<button id="ptCancel">${t('cancel')}</button><button class="primary" id="ptDone">✓ ${t('pt_done')}</button></div>`;
$('shop').appendChild(panel);
(host || $('shop')).appendChild(panel);
const cv = $('ptCv');
cv.addEventListener('pointerdown', down);
cv.addEventListener('pointermove', move);
@@ -157,19 +157,24 @@
});
}
function open() {
if (!panel) build();
function open(mountEl) {
const inline = !!mountEl;
if (!panel) build(mountEl || $('shop'));
else if (mountEl && panel.parentNode !== mountEl) mountEl.appendChild(panel);
panel.classList.toggle('inline', inline);
before = lc.getImageData(0, 0, LW, LH);
undo = [];
panel.style.display = '';
$('sRight').style.display = 'none'; $('shop').classList.add('painting');
if (!inline) { $('sRight').style.display = 'none'; $('shop').classList.add('painting'); }
opt.view.paintCam(true);
refresh(); live();
}
function close() {
if (!panel) return;
const inline = panel.classList.contains('inline');
panel.style.display = 'none';
$('sRight').style.display = ''; $('shop').classList.remove('painting');
if (!inline) $('sRight').style.display = '';
$('shop').classList.remove('painting');
opt.view.paintCam(false); opt.view.face(null);
}
// anything drawn at all? (decides stock stripes vs. own artwork on the model)
@@ -178,6 +183,6 @@
for (let i = 3; i < d.length; i += 16) if (d[i] > 8) return true;
return false;
}
return { open, close, hasArt, get isOpen() { return !!panel && panel.style.display !== 'none'; } };
return { open, close, hasArt, sync() { if (panel && panel.style.display !== 'none') { live(); refresh(); } }, get isOpen() { return !!panel && panel.style.display !== 'none'; } };
};
})(window);