| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- /**
- * boxlib.js — 盒型库 / 模板 / 素材 / 纹理 / 动效 / 色板 数据层
- * 对标包小盒「盒型库 · 模板 · 素材 · 动效」的数据组织方式。
- */
- (function () {
- 'use strict';
- /* ---------------- 盒型库 ---------------- */
- // gen: 刀版生成结构;sizes: 固定尺寸(可改尺寸为 null);mats: 可选材质
- var BOXLIB = [
- { no: '100010', name: '反向插锁盒', cat: '纸盒', gen: 'tuck', sizes: null, printable: true, hot: 5 },
- { no: '100011', name: '直插盒', cat: '纸盒', gen: 'straight', sizes: null, printable: true, hot: 3 },
- { no: '100020', name: '卡纸折叠盒', cat: '纸盒', gen: 'carton', sizes: null, printable: true, hot: 5 },
- { no: '100030', name: '飞机式插锁盒', cat: '纸盒', gen: 'mailer', sizes: null, printable: true, hot: 4 },
- { no: '100040', name: '扣底盒', cat: '纸盒', gen: 'autobottom', sizes: null, printable: true, hot: 4 },
- { no: '100050', name: '平口箱', cat: '纸箱', gen: 'rsc', sizes: null, printable: true, hot: 3 },
- { no: '100060', name: '四折边对盖盒', cat: '纸箱', gen: 'rsc', sizes: [[200, 140, 80], [260, 180, 100]], printable: true, hot: 2 },
- { no: '360110', name: '异型书型精品翻盖礼盒', cat: '精装盒', gen: 'mailbox', sizes: [[220, 60, 160]], printable: true, hot: 3 },
- { no: '360120', name: '翻盖精品礼盒', cat: '精装盒', gen: 'mailbox', sizes: null, printable: true, hot: 4 },
- { no: '360130', name: '到底V槽天地盖盒', cat: '精装盒', gen: 'drawer', sizes: [[180, 120, 60]], printable: true, hot: 2 },
- { no: '360140', name: '抽屉盒', cat: '精装盒', gen: 'drawer', sizes: null, printable: true, hot: 3 },
- { no: '220010', name: '手提袋', cat: '手提袋', gen: 'bag', sizes: [[200, 100, 260], [250, 120, 320], [300, 140, 400]], printable: true, hot: 5 },
- { no: '220013', name: '平口手提袋', cat: '手提袋', gen: 'bag', sizes: [[200, 100, 260]], printable: true, hot: 2 },
- { no: '220041', name: '弧形孔手提袋', cat: '手提袋', gen: 'bag', sizes: [[220, 110, 300]], printable: true, hot: 2 },
- { no: '220040', name: '免提手袋', cat: '手提袋', gen: 'bag', sizes: [[180, 90, 240]], printable: false, hot: 1 },
- { no: '240010', name: '封套', cat: '封套/卡片/文件', gen: 'sleeve', sizes: null, printable: true, hot: 3 },
- { no: '240030', name: '梯形盒套', cat: '封套/卡片/文件', gen: 'sleeve', sizes: [[160, 60, 220]], printable: true, hot: 1 },
- { no: '240090', name: '快餐盒封套', cat: '封套/卡片/文件', gen: 'sleeve', sizes: [[200, 90, 60]], printable: true, hot: 1 },
- { no: '260030', name: '矩形卡牌', cat: '封套/卡片/文件', gen: 'card', sizes: [[90, 54], [85, 54]], printable: true, hot: 2 },
- { no: '260040', name: '圆形卡牌', cat: '封套/卡片/文件', gen: 'card', sizes: [[80, 80]], printable: true, hot: 1 },
- { no: '261010', name: '矩形吊牌', cat: '封套/卡片/文件', gen: 'card', sizes: [[50, 90], [60, 100]], printable: true, hot: 2 },
- { no: '261002', name: '椭圆形吊牌', cat: '封套/卡片/文件', gen: 'card', sizes: [[60, 95]], printable: true, hot: 1 },
- { no: '270010', name: '矩形标签', cat: '封套/卡片/文件', gen: 'card', sizes: [[60, 40], [80, 50]], printable: true, hot: 2 },
- { no: '270020', name: '圆形标签', cat: '封套/卡片/文件', gen: 'card', sizes: [[50, 50]], printable: true, hot: 2 }
- ];
- var BOX_CATS = ['热门', '纸盒', '精装盒', '手提袋', '封套/卡片/文件', '更多'];
- function boxById(no) {
- return BOXLIB.find(function (b) { return b.no === no; }) || null;
- }
- /* ---------------- 模板 ---------------- */
- // 模板 = 各外表面预设(颜色 / 文字 / 素材),套用时自动适配当前印刷面尺寸
- var TEMPLATES = [
- {
- id: 't1', name: '苹果果汁软糖塑料袋包装设计', cat: '食品饮料', pro: false,
- face: 'front', color: '#fde9d2', texts: [
- { text: '苹果果汁软糖', size: 16, weight: 800, color: '#c2451f', align: 'center', x: 50, y: 34 },
- { text: 'APPLE JUICE GUMMY · 净含量 120g', size: 5, weight: 400, color: '#8a6a4a', align: 'center', x: 50, y: 52 }
- ], asset: { id: 'apple' }
- },
- { id: 't2', name: '西瓜味雪糕包装设计', cat: '食品饮料', pro: true, face: 'front', color: '#ffe3ea', texts: [{ text: '西瓜味雪糕', size: 15, weight: 800, color: '#e0486c', align: 'center', x: 50, y: 38 }, { text: 'WATERMELON ICE CREAM', size: 4.5, weight: 600, color: '#b25a70', align: 'center', x: 50, y: 50 }], asset: null },
- { id: 't3', name: '橙汁饮料玻璃瓶包装设计', cat: '食品饮料', pro: false, face: 'front', color: '#ffe9c9', texts: [{ text: '鲜榨橙汁', size: 16, weight: 800, color: '#e07c1f', align: 'center', x: 50, y: 36 }, { text: 'ORANGE JUICE 100%', size: 4.5, weight: 600, color: '#a06a30', align: 'center', x: 50, y: 48 }], asset: null },
- { id: 't4', name: '巧克力冰淇淋', cat: '食品饮料', pro: true, face: 'front', color: '#6b4a32', texts: [{ text: '巧克力冰淇淋', size: 14, weight: 800, color: '#ffe6c8', align: 'center', x: 50, y: 40 }, { text: 'CHOCOLATE ICE CREAM', size: 4.2, weight: 400, color: '#d9b898', align: 'center', x: 50, y: 52 }], asset: null },
- { id: 't5', name: '数码家电开箱盒', cat: '数码家电', pro: true, face: 'front', color: '#20242c', texts: [{ text: 'SMART HOME', size: 13, weight: 800, color: '#ffffff', align: 'center', x: 50, y: 36 }, { text: '智能家庭中枢 · 2代', size: 5, weight: 400, color: '#9aa3b2', align: 'center', x: 50, y: 48 }], asset: null },
- { id: 't6', name: '蓝牙耳机天地盖盒', cat: '数码家电', pro: false, face: 'front', color: '#eef1f5', texts: [{ text: 'AIR BUDS', size: 14, weight: 800, color: '#1c2733', align: 'center', x: 50, y: 38 }, { text: '真无线降噪耳机', size: 5, weight: 600, color: '#5c6b7c', align: 'center', x: 50, y: 50 }], asset: null },
- { id: 't7', name: '乌龙茶饮包装', cat: '日常用品', pro: false, face: 'front', color: '#e8f2e4', texts: [{ text: '乌龙茶', size: 17, weight: 800, color: '#2e5c3a', align: 'center', x: 50, y: 36 }, { text: '无糖 · 零卡 · 冷泡', size: 5, weight: 400, color: '#6a8a70', align: 'center', x: 50, y: 50 }], asset: null },
- { id: 't8', name: '香氛蜡烛礼盒', cat: '日常用品', pro: true, face: 'front', color: '#f4ece2', texts: [{ text: 'Perfume', size: 15, weight: 400, color: '#7a5c48', align: 'center', x: 50, y: 38, italic: true }, { text: 'SCENTED CANDLE · 200g', size: 4.2, weight: 400, color: '#a08868', align: 'center', x: 50, y: 50 }], asset: null },
- { id: 't9', name: '美妆精华简约盒', cat: '日常用品', pro: false, face: 'front', color: '#ffffff', texts: [{ text: 'GLOW SERUM', size: 13, weight: 700, color: '#c9a15c', align: 'center', x: 50, y: 40, italic: true }, { text: '焕采精华液 30ml', size: 5, weight: 400, color: '#8a7a5c', align: 'center', x: 50, y: 52 }], asset: null },
- { id: 't10', name: '电商发货飞机盒', cat: '热门', pro: false, face: 'front', color: '#d7b17c', texts: [{ text: 'THANK YOU', size: 13, weight: 800, color: '#6a4a26', align: 'center', x: 50, y: 40 }, { text: '轻拿轻放 · 易碎品', size: 5, weight: 400, color: '#8a6a46', align: 'center', x: 50, y: 52 }], asset: { id: 'fragile' } },
- { id: 't11', name: '精品手提袋', cat: '热门', pro: true, face: 'front', color: '#2c2c2e', texts: [{ text: 'GIFT', size: 15, weight: 700, color: '#e8c88a', align: 'center', x: 50, y: 40, italic: true }, { text: '精品礼遇 · 有档次', size: 4.5, weight: 400, color: '#b8a888', align: 'center', x: 50, y: 52 }], asset: null },
- { id: 't12', name: '中秋月饼礼盒', cat: '热门', pro: false, face: 'front', color: '#a3372c', texts: [{ text: '中秋礼遇', size: 16, weight: 800, color: '#f7e2b8', align: 'center', x: 50, y: 36 }, { text: 'FLOWER MOONCAKE', size: 4.2, weight: 400, color: '#e0b890', align: 'center', x: 50, y: 50 }], asset: null }
- ];
- var TEMPLATE_CATS = ['热门', '食品饮料', '数码家电', '日常用品', '更多'];
- /* ---------------- 素材库(内联 SVG) ---------------- */
- var ICONS = {
- recycle: { name: '回收标志', svg: '<path d="M12 4l3.2 5.5h-2.1L12 7.2 9.6 11H7.5L12 4Zm6.5 10.5-2-3.4 2.1-.1 1.2 2.1-1.3 1.4ZM6 14.4l1.9-3.3 1.1 1.8-1.2 2.1H6v-.6Zm2 3.6h4.4l-1 1.9H7.2L8 18Zm8.6 0H14l1.9-3.4h2.2L17 18h-.4Z" fill="currentColor"/><path d="M12 4 8.8 9.5M12 4l3.2 5.5M5.6 18.4 8 13.6m8.5 4.9-2.3-4.9" stroke="currentColor" stroke-width=".8" fill="none"/>' },
- up: { name: '向上', svg: '<path d="M12 19V6M6.5 11.5 12 6l5.5 5.5" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M5 20.5h14" stroke="currentColor" stroke-width="1.6"/>' },
- umbrella: { name: '防雨', svg: '<path d="M12 4a8 8 0 0 1 8 8H4a8 8 0 0 1 8-8Z" fill="currentColor"/><path d="M12 12v6a2 2 0 0 0 4 0" fill="none" stroke="currentColor" stroke-width="1.6"/>' },
- dry: { name: '防潮 / 保持干燥', svg: '<path d="M7 15a4 4 0 1 1 .6-7.9A5 5 0 0 1 17 9a3.5 3.5 0 0 1-.5 6.9H7Z" fill="currentColor"/><path d="M9 19.5h6M10.5 21.5h3" stroke="currentColor" stroke-width="1.5"/>' },
- fragile: { name: '易碎品(酒杯)', svg: '<path d="M8.5 4h7l-.6 6a3 3 0 0 1-2.4 2.7V18h2.3v1.6H9.2V18h2.3v-5.3A3 3 0 0 1 9.1 10L8.5 4Z" fill="currentColor"/>' },
- stack: { name: '堆码层数', svg: '<path d="M5 18.5h14M5 15h14M6.5 11.5h11M8 8h8l-1-3.5H9L8 8Z" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="16.2" y="6.4" font-size="6" font-weight="700" fill="currentColor">4</text>' },
- careful: { name: '小心棱角', svg: '<path d="M12 4 21 19H3L12 4Z" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"/><path d="M12 10v4.2" stroke="currentColor" stroke-width="1.7"/><circle cx="12" cy="16.6" r=".95" fill="currentColor"/>' },
- ce: { name: 'CE 认证', svg: '<path d="M15.5 8.4a4.2 4.2 0 1 0 0 7.2M17.8 9.6a4.2 4.2 0 0 0-2.3-.9" fill="none" stroke="currentColor" stroke-width="1.7"/><circle cx="6.4" cy="9.4" r="1.7" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="M6.4 11.1v4.9M5 12.5h2.8" stroke="currentColor" stroke-width="1.4" fill="none"/>' },
- fda: { name: 'FDA', svg: '<rect x="3.5" y="3.5" width="17" height="17" rx="2" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="12" y="15.2" font-size="6.4" font-weight="800" text-anchor="middle" fill="currentColor">FDA</text>' },
- rohs: { name: 'RoHS', svg: '<circle cx="12" cy="12" r="8.4" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="12" y="14.4" font-size="5.4" font-weight="800" text-anchor="middle" fill="currentColor">RoHS</text>' },
- fc: { name: 'FC 认证', svg: '<rect x="3.5" y="3.5" width="17" height="17" rx="2" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="12" y="15" font-size="7" font-weight="800" text-anchor="middle" fill="currentColor">FC</text>' },
- ccc: { name: 'CCC', svg: '<circle cx="12" cy="12" r="8.4" fill="none" stroke="currentColor" stroke-width="1.5"/><text x="12" y="14.2" font-size="5.2" font-weight="800" text-anchor="middle" fill="currentColor">CCC</text>' },
- green: { name: '绿点回收', svg: '<circle cx="12" cy="12" r="8.4" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 12.2 11 15l5-6" fill="none" stroke="currentColor" stroke-width="1.8"/>' },
- iso: { name: 'ISO 质量', svg: '<circle cx="12" cy="12" r="8.4" fill="none" stroke="currentColor" stroke-width="1.4"/><text x="12" y="11" font-size="4.6" font-weight="800" text-anchor="middle" fill="currentColor">ISO</text><text x="12" y="16" font-size="4" font-weight="600" text-anchor="middle" fill="currentColor">9001</text>' },
- noLitter: { name: '请勿乱扔', svg: '<path d="M6 6l12 12M18 6 6 18" stroke="currentColor" stroke-width="1.8"/><path d="M5 19c2-3 5-4 7-4s5 1 7 4" fill="none" stroke="currentColor" stroke-width="1.4"/>' },
- battery: { name: '电子回收', svg: '<rect x="7" y="6" width="10" height="15" rx="1.4" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M10 3.6h4V6h-4z" fill="currentColor"/><path d="M9.5 9.5 7 12.6h3.4L9 15.8l4.5-4.4h-3l1.6-1.9z" fill="currentColor"/>' },
- apple: { name: '苹果', svg: '<path d="M12 8.6c1.4-1.6 3.4-1.8 4.8-.6 1.8 1.6 1.6 4.6.2 7-1 1.7-2.2 2.9-3.5 2.9-.8 0-1-.4-1.5-.4s-.8.4-1.5.4c-1.3 0-2.5-1.2-3.5-2.9-1.4-2.4-1.6-5.4.2-7 1.4-1.2 3.4-1 4.8.6Z" fill="currentColor"/><path d="M12 8.2c0-1.6 1-2.9 2.6-3.2" fill="none" stroke="currentColor" stroke-width="1.3"/>' },
- leaf: { name: '叶子环保', svg: '<path d="M18.5 5.5c.4 6.8-2.8 11.4-8.4 12.3-2.4.4-4.4-.4-5.4-1.6 1-4.4 4.6-8.4 13.8-10.7Z" fill="currentColor"/><path d="M5.5 18.5C8 13 12 9.5 17 7.5" stroke="#fff" stroke-width="1" fill="none" opacity=".55"/>' },
- heart: { name: '爱心', svg: '<path d="M12 19.5S4.5 14.8 4.5 9.9C4.5 7.4 6.5 5.5 9 5.5c1.3 0 2.4.6 3 1.5.6-.9 1.7-1.5 3-1.5 2.5 0 4.5 1.9 4.5 4.4 0 4.9-7.5 9.6-7.5 9.6Z" fill="currentColor"/>' },
- star: { name: '星星', svg: '<path d="m12 4 2.4 5 5.6.7-4.1 3.8 1.1 5.5L12 16.3 7 19l1.1-5.5L4 9.7l5.6-.7L12 4Z" fill="currentColor"/>' }
- };
- var SHAPES = {
- square: { name: '方形', draw: 'rect' },
- circle: { name: '圆形', draw: 'circle' },
- triangle: { name: '三角形', draw: 'triangle' },
- ring: { name: '圆环', draw: 'ring' },
- line: { name: '横线', draw: 'line' },
- ribbon: { name: '丝带横幅', draw: 'ribbon' },
- badge: { name: '圆形徽章', draw: 'badge' },
- rounded: { name: '圆角框', draw: 'rounded' }
- };
- var ASSET_CATS = ['全部', '形状', '图标', '插画', '抠图'];
- function assetSvg(id, color) {
- var ic = ICONS[id];
- if (ic) return '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">' + ic.svg.replace(/currentColor/g, color || '#17140f') + '</svg>';
- return null;
- }
- // 形状素材 → canvas dataURL
- function shapeDataUrl(kind, color, size) {
- var c = document.createElement('canvas');
- c.width = c.height = size || 160;
- var ctx = c.getContext('2d');
- ctx.fillStyle = color || '#17140f';
- var s = c.width;
- if (kind === 'rect') ctx.fillRect(s * 0.1, s * 0.28, s * 0.8, s * 0.44);
- if (kind === 'circle') { ctx.beginPath(); ctx.arc(s / 2, s / 2, s * 0.36, 0, 7); ctx.fill(); }
- if (kind === 'triangle') { ctx.beginPath(); ctx.moveTo(s / 2, s * 0.16); ctx.lineTo(s * 0.86, s * 0.8); ctx.lineTo(s * 0.14, s * 0.8); ctx.closePath(); ctx.fill(); }
- if (kind === 'ring') { ctx.lineWidth = s * 0.1; ctx.strokeStyle = ctx.fillStyle; ctx.beginPath(); ctx.arc(s / 2, s / 2, s * 0.3, 0, 7); ctx.stroke(); }
- if (kind === 'line') ctx.fillRect(s * 0.1, s * 0.46, s * 0.8, s * 0.07);
- if (kind === 'ribbon') { ctx.beginPath(); ctx.moveTo(s * 0.08, s * 0.36); ctx.lineTo(s * 0.92, s * 0.36); ctx.lineTo(s * 0.84, s * 0.5); ctx.lineTo(s * 0.92, s * 0.64); ctx.lineTo(s * 0.08, s * 0.64); ctx.lineTo(s * 0.16, s * 0.5); ctx.closePath(); ctx.fill(); }
- if (kind === 'badge') { ctx.beginPath(); ctx.arc(s / 2, s / 2, s * 0.34, 0, 7); ctx.fill(); ctx.globalCompositeOperation = 'destination-out'; ctx.beginPath(); ctx.arc(s / 2, s / 2, s * 0.24, 0, 7); ctx.fill(); ctx.globalCompositeOperation = 'source-over'; }
- if (kind === 'rounded') { ctx.lineWidth = s * 0.06; ctx.strokeStyle = ctx.fillStyle; var r = s * 0.12; ctx.beginPath(); ctx.moveTo(s * 0.14 + r, s * 0.22); ctx.arcTo(s * 0.86, s * 0.22, s * 0.86, s * 0.78, r); ctx.arcTo(s * 0.86, s * 0.78, s * 0.14, s * 0.78, r); ctx.arcTo(s * 0.14, s * 0.78, s * 0.14, s * 0.22, r); ctx.arcTo(s * 0.14, s * 0.22, s * 0.86, s * 0.22, r); ctx.closePath(); ctx.stroke(); }
- return c.toDataURL('image/png');
- }
- /* ---------------- 纹理库(程序化生成) ---------------- */
- var TEXTURES = [
- { id: 'kraft', name: '牛皮纸纹', gen: 'kraft' },
- { id: 'dots', name: '圆点', gen: 'dots' },
- { id: 'stripe', name: '斜条纹', gen: 'stripe' },
- { id: 'linen', name: '亚麻', gen: 'linen' },
- { id: 'floral', name: '碎花', gen: 'floral' },
- { id: 'marble', name: '大理石', gen: 'marble' }
- ];
- function textureDataUrl(id) {
- var c = document.createElement('canvas');
- c.width = c.height = 220;
- var ctx = c.getContext('2d');
- var t = TEXTURES.find(function (x) { return x.id === id; });
- if (!t) return null;
- if (t.gen === 'kraft') {
- ctx.fillStyle = '#d9b98a'; ctx.fillRect(0, 0, 220, 220);
- for (var i = 0; i < 260; i += 1) {
- ctx.strokeStyle = 'rgba(150,110,60,' + (0.05 + Math.random() * 0.1) + ')';
- ctx.lineWidth = 0.7;
- var x = Math.random() * 220, y = Math.random() * 220;
- ctx.beginPath(); ctx.moveTo(x, y);
- ctx.quadraticCurveTo(x + 14, y + (Math.random() * 8 - 4), x + 30, y + (Math.random() * 6 - 3));
- ctx.stroke();
- }
- } else if (t.gen === 'dots') {
- ctx.fillStyle = '#f6efe2'; ctx.fillRect(0, 0, 220, 220);
- ctx.fillStyle = '#e2b8a0';
- for (var a = 0; a < 7; a += 1) for (var b = 0; b < 7; b += 1) {
- ctx.beginPath(); ctx.arc(16 + a * 32 + (b % 2) * 16, 16 + b * 32, 4.5, 0, 7); ctx.fill();
- }
- } else if (t.gen === 'stripe') {
- ctx.fillStyle = '#f2ede2'; ctx.fillRect(0, 0, 220, 220);
- ctx.strokeStyle = 'rgba(150,140,120,.35)'; ctx.lineWidth = 7;
- for (var s2 = -220; s2 < 440; s2 += 30) { ctx.beginPath(); ctx.moveTo(s2, 0); ctx.lineTo(s2 + 220, 220); ctx.stroke(); }
- } else if (t.gen === 'linen') {
- ctx.fillStyle = '#efe9db'; ctx.fillRect(0, 0, 220, 220);
- for (var v = 0; v < 220; v += 4) { ctx.strokeStyle = 'rgba(120,110,90,.10)'; ctx.beginPath(); ctx.moveTo(v, 0); ctx.lineTo(v, 220); ctx.stroke(); }
- for (var h2 = 0; h2 < 220; h2 += 4) { ctx.strokeStyle = 'rgba(120,110,90,.08)'; ctx.beginPath(); ctx.moveTo(0, h2); ctx.lineTo(220, h2); ctx.stroke(); }
- } else if (t.gen === 'floral') {
- ctx.fillStyle = '#f7f1e8'; ctx.fillRect(0, 0, 220, 220);
- for (var f = 0; f < 9; f += 1) {
- var fx = Math.random() * 220, fy = Math.random() * 220;
- ctx.fillStyle = ['#e8b8c0', '#b8c8e0', '#e0d0a0'][f % 3];
- for (var p = 0; p < 5; p += 1) {
- ctx.beginPath();
- ctx.ellipse(fx + Math.cos(p / 5 * 6.28) * 7, fy + Math.sin(p / 5 * 6.28) * 7, 5.5, 3.4, p / 5 * 6.28, 0, 7);
- ctx.fill();
- }
- ctx.fillStyle = '#c8a860'; ctx.beginPath(); ctx.arc(fx, fy, 2.6, 0, 7); ctx.fill();
- }
- } else if (t.gen === 'marble') {
- ctx.fillStyle = '#f0eee9'; ctx.fillRect(0, 0, 220, 220);
- for (var m = 0; m < 26; m += 1) {
- ctx.strokeStyle = 'rgba(120,118,110,' + (0.08 + Math.random() * 0.16) + ')';
- ctx.lineWidth = 0.6 + Math.random() * 1.6;
- var mx = Math.random() * 220, my = Math.random() * 220;
- ctx.beginPath(); ctx.moveTo(mx, my);
- ctx.bezierCurveTo(mx + 40, my + 30 * (Math.random() - 0.5), mx + 80, my - 30 * (Math.random() - 0.5), mx + 130, my + 20 * (Math.random() - 0.5));
- ctx.stroke();
- }
- }
- return c.toDataURL('image/jpeg', 0.85);
- }
- /* ---------------- 3D 快捷色板(包小盒马卡龙色) ---------------- */
- var SWATCHES = ['#f6d4d4', '#f8ddc8', '#d8e4f8', '#e2d9f6', '#ffffff', '#f6ecd4', '#f8d8e4', '#e6e6e6', '#b9c2cc', '#5b7ba6'];
- var FACE_COLORS = ['#e5484d', '#3b82f6', '#22c55e', '#f59e0b', '#fde68a', '#17140f', '#2dd4bf', '#ec4899', '#a16207', '#94a3b8'];
- /* ---------------- 动效(10 种,与包小盒一一对应) ---------------- */
- var ANIMS = [
- { id: 'fold', name: '折叠展开', dur: 4 },
- { id: 'spinFlat', name: '物体平视自转一圈', dur: 5 },
- { id: 'spinTop', name: '物体俯视自转一周', dur: 3 },
- { id: 'dropSpin', name: '旋转掉落', dur: 4 },
- { id: 'zoomIn', name: '由远到近', dur: 4 },
- { id: 'dropZoom', name: '掉落后放大细节', dur: 8 },
- { id: 'zoomDetail', name: '由远到近放大细节', dur: 4 },
- { id: 'fromLeft', name: '从左侧旋转入场', dur: 5 },
- { id: 'curveIn', name: '由远到近曲线入场', dur: 5 },
- { id: 'foldBounce', name: '折叠动画弹跳入场', dur: 5 }
- ];
- window.PL = window.PL || {};
- window.PL.boxlib = {
- BOXLIB: BOXLIB, BOX_CATS: BOX_CATS, boxById: boxById,
- TEMPLATES: TEMPLATES, TEMPLATE_CATS: TEMPLATE_CATS,
- ICONS: ICONS, SHAPES: SHAPES, ASSET_CATS: ASSET_CATS, assetSvg: assetSvg, shapeDataUrl: shapeDataUrl,
- TEXTURES: TEXTURES, textureDataUrl: textureDataUrl,
- SWATCHES: SWATCHES, FACE_COLORS: FACE_COLORS,
- ANIMS: ANIMS
- };
- })();
|