显卡完善

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) => {
const asset = this.addProgramPreviewAssets[zIdx];
if (!asset) return;
const state = this.addProgramPreviewAnimState[zIdx] || {};
// 90270x/y/width/height
let zoneX, zoneY, zoneWidth, zoneHeight;
@ -2512,12 +2513,9 @@ export default {
ctx.rect(zoneX, zoneY, zoneWidth, zoneHeight);
ctx.clip();
//
const state = this.addProgramPreviewAnimState[zIdx];
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] || [];
//
@ -2589,7 +2587,7 @@ export default {
ctx.fillText(line, x1, y);
ctx.fillText(line, x2, y);
} 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) {
@ -2795,7 +2793,7 @@ export default {
zoneRenderHeight: (swapWH ? zone.width : zone.height) * scale
};
});
},
},
resetAddProgramPreviewPage() {
this.addProgramPreviewPage = this.addProgramForm.zones.map(() => 0);
},
@ -2864,17 +2862,20 @@ export default {
return { lines, maxLines };
},
resetAddProgramPreviewAnimState() {
//
this.addProgramPreviewAnimState = this.addProgramForm.zones.map((zone, idx) => {
return {
currentX: 0,
currentY: 0,
currentPage: this.addProgramPreviewPage[idx] || 0,
pageTimer: null,
currentPage: 0,
isMoving: false,
isPausing: false,
moveStart: 0,
pauseStart: 0,
currentChar: 0, //
effect: zone.effect,
};
});
},
},
stopAddProgramPreviewAnimLoop() {
if (this.addProgramPreviewAnimFrame) {
cancelAnimationFrame(this.addProgramPreviewAnimFrame);
@ -2910,8 +2911,7 @@ export default {
if (!asset || !state || !asset.isText) return;
const effect = zone.effect;
const page = this.addProgramPreviewPage[idx] || 0;
const pageLines = asset.pages[page] || [];
const pageLines = asset.pages[state.currentPage] || [];
const lineHeight = asset.lineHeight;
const totalHeight = asset.totalHeight;
const totalWidth = asset.totalWidth;
@ -2928,70 +2928,186 @@ export default {
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.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) {
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: //
if (typeof state.currentX !== 'number') state.currentX = zoneWidth;
state.currentX -= animSpeed;
if (state.currentX < -totalWidth) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
}
if (!state.isMoving && !state.isPausing) {
//
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;
break;
case 2: //
if (typeof state.currentX !== 'number') state.currentX = -totalWidth;
state.currentX += animSpeed;
if (state.currentX > zoneWidth) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
}
if (!state.isMoving && !state.isPausing) {
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;
break;
case 3: //
if (typeof state.currentY !== 'number') state.currentY = zoneHeight;
state.currentY -= animSpeed;
if (state.currentY < -totalHeight) {
if (asset.pages.length > 1) {
state.currentPage = (state.currentPage + 1) % asset.pages.length;
}
if (!state.isMoving && !state.isPausing) {
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;
break;
case 4: //
if (typeof state.currentY !== 'number') state.currentY = -totalHeight;
state.currentY += animSpeed;
if (state.currentY > zoneHeight) {
if (asset.pages.length > 1) {
} 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.currentY = zoneHeight;
state.isMoving = true;
state.moveStart = Date.now();
}
state.currentX = 0;
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: // ()
//
// -
if (typeof state.currentX !== 'number') state.currentX = zoneWidth;
//
state.currentX -= animSpeed;
//
if (state.currentX < -totalWidth) {
state.currentX += totalWidth;
}
// Y
state.currentY = (zoneHeight - totalHeight) / 2;
break;
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.currentY = 0;
break;
@ -3002,7 +3118,7 @@ export default {
break;
}
});
},
},
measureTextWidth(text, asset) {
//
const canvas = document.createElement('canvas');