|
|
@@ -378,16 +378,24 @@
|
|
|
|
|
|
if (type === 'rsc') {
|
|
|
[[xF, W, 'top', true], [xR, D2, null, false], [xB, W, null, false], [xL, D2, null, false]].forEach(function (f) {
|
|
|
- panels.push(rect(f[0], -half, f[1], half, f[2], 'flap'));
|
|
|
- panels.push(rect(f[0], H, f[1], half, f[3] ? 'bottom' : null, 'flap'));
|
|
|
+ const top = rect(f[0], -half, f[1], half, f[2], 'flap');
|
|
|
+ if (!f[2]) top.paint = 'top';
|
|
|
+ panels.push(top);
|
|
|
+ const bottom = rect(f[0], H, f[1], half, f[3] ? 'bottom' : null, 'flap');
|
|
|
+ if (!f[3]) bottom.paint = 'bottom';
|
|
|
+ panels.push(bottom);
|
|
|
});
|
|
|
} else if (type === 'carton') {
|
|
|
panels.push(big(xF, 0, 'top', -1));
|
|
|
- panels.push(big(xB, 0, null, -1));
|
|
|
+ const topBack = big(xB, 0, null, -1);
|
|
|
+ topBack.paint = 'top';
|
|
|
+ panels.push(topBack);
|
|
|
panels.push(dust(xR, 0, -1));
|
|
|
panels.push(dust(xL, 0, -1));
|
|
|
panels.push(big(xF, H, 'bottom', 1));
|
|
|
- panels.push(big(xB, H, null, 1));
|
|
|
+ const bottomBack = big(xB, H, null, 1);
|
|
|
+ bottomBack.paint = 'bottom';
|
|
|
+ panels.push(bottomBack);
|
|
|
panels.push(dust(xR, H, 1));
|
|
|
panels.push(dust(xL, H, 1));
|
|
|
} else if (type === 'mailer') {
|
|
|
@@ -434,9 +442,15 @@
|
|
|
[xF, H], [xF + c2, H + d1], [xF + W * 0.32, H + d1], [xF + W * 0.32, H + d1 - 4],
|
|
|
[xF + W * 0.68, H + d1 - 4], [xF + W * 0.68, H + d1], [xF + W - c2, H + d1], [xF + W, H]
|
|
|
], 'bottom', 'flap'));
|
|
|
- panels.push(poly([[xB, H], [xB + c2, H + d2], [xB + W - c2, H + d2], [xB + W, H]], null, 'flap'));
|
|
|
- panels.push(poly([[xR, H], [xR + D2, H], [xR + D2 / 2, H + half + 3]], null, 'dust'));
|
|
|
- panels.push(poly([[xL, H], [xL + D2, H], [xL + D2 / 2, H + half + 3]], null, 'dust'));
|
|
|
+ const bottomBack = poly([[xB, H], [xB + c2, H + d2], [xB + W - c2, H + d2], [xB + W, H]], null, 'flap');
|
|
|
+ bottomBack.paint = 'bottom';
|
|
|
+ panels.push(bottomBack);
|
|
|
+ const bottomR = poly([[xR, H], [xR + D2, H], [xR + D2 / 2, H + half + 3]], null, 'dust');
|
|
|
+ bottomR.paint = 'bottom';
|
|
|
+ panels.push(bottomR);
|
|
|
+ const bottomL = poly([[xL, H], [xL + D2, H], [xL + D2 / 2, H + half + 3]], null, 'dust');
|
|
|
+ bottomL.paint = 'bottom';
|
|
|
+ panels.push(bottomL);
|
|
|
} else {
|
|
|
// tuck 反向插锁:下盖挂前板
|
|
|
panels.push(poly([[xF, H], [xF + ch, H + lidD], [xF + W - ch, H + lidD], [xF + W, H]], 'bottom', 'flap'));
|
|
|
@@ -828,6 +842,14 @@
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
+ function assetFillSrc(item, color) {
|
|
|
+ if (item.draw) return LB.shapeDataUrl(item.draw, color, 160);
|
|
|
+ if (item.svgDef) return 'data:image/svg+xml;utf8,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' + item.svgDef.replace(/currentColor/g, color) + '</svg>');
|
|
|
+ const id = String(item.assetId || '').replace(/^icon:/, '');
|
|
|
+ const svg = id ? LB.assetSvg(id, color) : null;
|
|
|
+ return svg ? 'data:image/svg+xml;utf8,' + encodeURIComponent(svg) : null;
|
|
|
+ }
|
|
|
+
|
|
|
function addAssetToFace(item) {
|
|
|
const face = curFace();
|
|
|
face.items = face.items || [];
|
|
|
@@ -990,7 +1012,7 @@
|
|
|
if (t.asset && LB.ICONS[t.asset.id]) {
|
|
|
face.items.push({
|
|
|
id: 'i' + Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
|
|
|
- type: 'asset', assetId: t.asset.id, src: 'data:image/svg+xml;utf8,' + encodeURIComponent(LB.assetSvg(t.asset.id, '#c2451f')), x: 50, y: 68, w: 26
|
|
|
+ type: 'asset', assetId: t.asset.id, src: 'data:image/svg+xml;utf8,' + encodeURIComponent(LB.assetSvg(t.asset.id, '#c2451f')), color: '#c2451f', x: 50, y: 68, w: 26
|
|
|
});
|
|
|
}
|
|
|
UI.message.success('模板「' + t.name + '」已套用到' + faceName(t.face));
|
|
|
@@ -1056,7 +1078,7 @@
|
|
|
let src;
|
|
|
if (a.svgDef) src = 'data:image/svg+xml;utf8,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">' + a.svgDef.replace(/currentColor/g, '#17140f') + '</svg>');
|
|
|
else src = LB.shapeDataUrl(a.draw, '#17140f', 160);
|
|
|
- addAssetToFace({ type: 'asset', assetId: a.id, name: a.name, src: src });
|
|
|
+ addAssetToFace({ type: 'asset', assetId: a.id, name: a.name, src: src, color: '#17140f', svgDef: a.svgDef || null, draw: a.draw || null });
|
|
|
}
|
|
|
|
|
|
/* ---- 文字面板 ---- */
|
|
|
@@ -1649,8 +1671,30 @@
|
|
|
)
|
|
|
));
|
|
|
} else {
|
|
|
+ const colorable = item.type === 'asset' && !!assetFillSrc(item, '#17140f');
|
|
|
rows.push(h('div', { className: 'bx-props-sec' },
|
|
|
h('img', { className: 'bx-item-preview', src: item.src, alt: '' }),
|
|
|
+ colorable && h('div', { className: 'p-field' }, h('label', null, '颜色'), h(A.ColorPicker, {
|
|
|
+ key: 'ac-' + item.id,
|
|
|
+ defaultValue: item.color || '#17140f',
|
|
|
+ showText: true,
|
|
|
+ onChange: function (c) {
|
|
|
+ const hex = c.toHexString();
|
|
|
+ const next = assetFillSrc(item, hex);
|
|
|
+ if (!next) return;
|
|
|
+ item.color = hex;
|
|
|
+ item.src = next;
|
|
|
+ save(true); renderDieline(); render3d(); renderMini();
|
|
|
+ },
|
|
|
+ onChangeComplete: function (c) {
|
|
|
+ const hex = c.toHexString();
|
|
|
+ const next = assetFillSrc(item, hex);
|
|
|
+ if (!next) return;
|
|
|
+ item.color = hex;
|
|
|
+ item.src = next;
|
|
|
+ commit();
|
|
|
+ }
|
|
|
+ })),
|
|
|
h('div', { className: 'p-field' }, h('label', null, '宽度 ' + (item.w == null ? 60 : item.w) + '%'), h(A.Slider, { value: item.w == null ? 60 : item.w, min: 8, max: 100, onChange: function (v) { item.w = v; renderDieline(); render3d(); renderMini(); }, onAfterChange: function () { commit(); } }))
|
|
|
));
|
|
|
}
|