显卡完善

This commit is contained in:
1 2025-07-25 19:55:12 +08:00
parent 2355147ed5
commit 7236a95236

View File

@ -2483,6 +2483,7 @@ export default {
this.addProgramForm.zones.forEach((zone, zIdx) => { this.addProgramForm.zones.forEach((zone, zIdx) => {
const asset = this.addProgramPreviewAssets[zIdx]; const asset = this.addProgramPreviewAssets[zIdx];
if (!asset) return; if (!asset) return;
const state = this.addProgramPreviewAnimState[zIdx] || {};
// 90270x/y/width/height // 90270x/y/width/height
let zoneX, zoneY, zoneWidth, zoneHeight; let zoneX, zoneY, zoneWidth, zoneHeight;
@ -2512,12 +2513,9 @@ export default {
ctx.rect(zoneX, zoneY, zoneWidth, zoneHeight); ctx.rect(zoneX, zoneY, zoneWidth, zoneHeight);
ctx.clip(); ctx.clip();
//
const state = this.addProgramPreviewAnimState[zIdx];
if (zone.playType === 0 && asset.isText) { if (zone.playType === 0 && asset.isText) {
// // 使
const page = state && typeof state.currentPage === 'number' ? state.currentPage : 0; const page = state.currentPage || 0;
const pageLines = asset.pages[page] || []; const pageLines = asset.pages[page] || [];
// //
@ -2589,7 +2587,7 @@ export default {
ctx.fillText(line, x1, y); ctx.fillText(line, x1, y);
ctx.fillText(line, x2, y); ctx.fillText(line, x2, y);
} else { } else {
ctx.fillText(line, startX + (state ? state.currentX : 0), startY + lineIdx * lineHeight + (state ? state.currentY : 0)); ctx.fillText(line, startX + animOffsetX, startY + lineIdx * lineHeight + animOffsetY);
} }
}); });
} else if (zone.playType === 1 && asset.isImage) { } else if (zone.playType === 1 && asset.isImage) {
@ -2864,13 +2862,16 @@ export default {
return { lines, maxLines }; return { lines, maxLines };
}, },
resetAddProgramPreviewAnimState() { resetAddProgramPreviewAnimState() {
//
this.addProgramPreviewAnimState = this.addProgramForm.zones.map((zone, idx) => { this.addProgramPreviewAnimState = this.addProgramForm.zones.map((zone, idx) => {
return { return {
currentX: 0, currentX: 0,
currentY: 0, currentY: 0,
currentPage: this.addProgramPreviewPage[idx] || 0, currentPage: 0,
pageTimer: null, isMoving: false,
isPausing: false,
moveStart: 0,
pauseStart: 0,
currentChar: 0, //
effect: zone.effect, effect: zone.effect,
}; };
}); });
@ -2910,8 +2911,7 @@ export default {
if (!asset || !state || !asset.isText) return; if (!asset || !state || !asset.isText) return;
const effect = zone.effect; const effect = zone.effect;
const page = this.addProgramPreviewPage[idx] || 0; const pageLines = asset.pages[state.currentPage] || [];
const pageLines = asset.pages[page] || [];
const lineHeight = asset.lineHeight; const lineHeight = asset.lineHeight;
const totalHeight = asset.totalHeight; const totalHeight = asset.totalHeight;
const totalWidth = asset.totalWidth; const totalWidth = asset.totalWidth;
@ -2928,70 +2928,186 @@ export default {
const pauseMs = this.getPauseTime(zone.stayTime); const pauseMs = this.getPauseTime(zone.stayTime);
// //
if (typeof state.isMoving !== 'boolean') state.isMoving = false;
if (typeof state.isPausing !== 'boolean') state.isPausing = false; if (typeof state.isPausing !== 'boolean') state.isPausing = false;
if (typeof state.pauseStart !== 'number') state.pauseStart = 0; if (typeof state.pauseStart !== 'number') state.pauseStart = 0;
if (typeof state.pausePhase !== 'string') state.pausePhase = 'start'; // 'start' | 'move' if (typeof state.moveStart !== 'number') state.moveStart = 0;
switch (effect) { switch (effect) {
case 0: //
if (!state.isPausing && !state.isMoving) {
//
state.isPausing = true;
state.pauseStart = Date.now();
} else if (state.isPausing) {
//
if (Date.now() - state.pauseStart >= pauseMs) {
state.isPausing = false;
state.isMoving = true; //
}
} else if (state.isMoving) {
//
state.currentPage = (state.currentPage + 1) % asset.pages.length;
state.isMoving = false;
state.isPausing = true;
state.pauseStart = Date.now();
}
//
state.currentX = 0;
state.currentY = 0;
break;
case 1: // case 1: //
if (typeof state.currentX !== 'number') state.currentX = zoneWidth; if (!state.isMoving && !state.isPausing) {
state.currentX -= animSpeed; //
if (state.currentX < -totalWidth) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
}
state.currentX = zoneWidth; state.currentX = zoneWidth;
state.isMoving = true;
state.moveStart = Date.now();
} else if (state.isMoving) {
//
const elapsed = Date.now() - state.moveStart;
const progress = Math.min(1, elapsed / (totalWidth * 1000 / animSpeed));
//
state.currentX = zoneWidth - progress * (zoneWidth + totalWidth);
//
if (progress >= 1) {
state.isMoving = false;
state.isPausing = true;
state.pauseStart = Date.now();
}
} else if (state.isPausing) {
//
if (Date.now() - state.pauseStart >= pauseMs) {
state.isPausing = false;
state.isMoving = true; //
}
} else if (!state.isPausing && state.isMoving) {
//
state.currentPage = (state.currentPage + 1) % asset.pages.length;
state.currentX = zoneWidth; //
state.isMoving = true;
state.moveStart = Date.now();
} }
state.currentY = 0; state.currentY = 0;
break; break;
case 2: // case 2: //
if (typeof state.currentX !== 'number') state.currentX = -totalWidth; if (!state.isMoving && !state.isPausing) {
state.currentX += animSpeed;
if (state.currentX > zoneWidth) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
}
state.currentX = -totalWidth; state.currentX = -totalWidth;
state.isMoving = true;
state.moveStart = Date.now();
} else if (state.isMoving) {
const elapsed = Date.now() - state.moveStart;
const progress = Math.min(1, elapsed / (totalWidth * 1000 / animSpeed));
state.currentX = -totalWidth + progress * (zoneWidth + totalWidth);
if (progress >= 1) {
state.isMoving = false;
state.isPausing = true;
state.pauseStart = Date.now();
}
} else if (state.isPausing) {
if (Date.now() - state.pauseStart >= pauseMs) {
state.isPausing = false;
state.isMoving = true; //
}
} else if (!state.isPausing && state.isMoving) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
state.currentX = -totalWidth;
state.isMoving = true;
state.moveStart = Date.now();
} }
state.currentY = 0; state.currentY = 0;
break; break;
case 3: // case 3: //
if (typeof state.currentY !== 'number') state.currentY = zoneHeight; if (!state.isMoving && !state.isPausing) {
state.currentY -= animSpeed;
if (state.currentY < -totalHeight) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
}
state.currentY = zoneHeight; state.currentY = zoneHeight;
state.isMoving = true;
state.moveStart = Date.now();
} else if (state.isMoving) {
const elapsed = Date.now() - state.moveStart;
const progress = Math.min(1, elapsed / (totalHeight * 1000 / animSpeed));
state.currentY = zoneHeight - progress * (zoneHeight + totalHeight);
if (progress >= 1) {
state.isMoving = false;
state.isPausing = true;
state.pauseStart = Date.now();
} }
state.currentX = 0; } else if (state.isPausing) {
break; if (Date.now() - state.pauseStart >= pauseMs) {
case 4: // state.isPausing = false;
if (typeof state.currentY !== 'number') state.currentY = -totalHeight; state.isMoving = true; //
state.currentY += animSpeed; }
if (state.currentY > zoneHeight) { } else if (!state.isPausing && state.isMoving) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length; state.currentPage = (state.currentPage + 1) % asset.pages.length;
} state.currentY = zoneHeight;
state.currentY = -totalHeight; state.isMoving = true;
state.moveStart = Date.now();
} }
state.currentX = 0; state.currentX = 0;
break; break;
case 4: //
if (!state.isMoving && !state.isPausing) {
state.currentY = -totalHeight;
state.isMoving = true;
state.moveStart = Date.now();
} else if (state.isMoving) {
const elapsed = Date.now() - state.moveStart;
const progress = Math.min(1, elapsed / (totalHeight * 1000 / animSpeed));
state.currentY = -totalHeight + progress * (zoneHeight + totalHeight);
if (progress >= 1) {
state.isMoving = false;
state.isPausing = true;
state.pauseStart = Date.now();
}
} else if (state.isPausing) {
if (Date.now() - state.pauseStart >= pauseMs) {
state.isPausing = false;
state.isMoving = true; //
}
} else if (!state.isPausing && state.isMoving) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
state.currentY = -totalHeight;
state.isMoving = true;
state.moveStart = Date.now();
}
state.currentX = 0;
break;
case 5: // () case 5: // ()
// // -
if (typeof state.currentX !== 'number') state.currentX = zoneWidth; if (typeof state.currentX !== 'number') state.currentX = zoneWidth;
//
state.currentX -= animSpeed; state.currentX -= animSpeed;
//
if (state.currentX < -totalWidth) { if (state.currentX < -totalWidth) {
state.currentX += totalWidth; state.currentX += totalWidth;
} }
// Y
state.currentY = (zoneHeight - totalHeight) / 2; state.currentY = (zoneHeight - totalHeight) / 2;
break; break;
case 6: // case 6: //
// if (!state.isPausing && !state.isMoving) {
state.isPausing = true;
state.pauseStart = Date.now();
} else if (state.isPausing) {
if (Date.now() - state.pauseStart >= pauseMs) {
state.isPausing = false;
state.isMoving = true; //
}
} else if (state.isMoving) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
state.isMoving = false;
state.isPausing = true;
state.pauseStart = Date.now();
}
state.currentX = 0; state.currentX = 0;
state.currentY = 0; state.currentY = 0;
break; break;