Prechádzať zdrojové kódy

fix: 简谱谱面优化

TIANYONG 1 rok pred
rodič
commit
2b6462c377
2 zmenil súbory, kde vykonal 31 pridanie a 2 odobranie
  1. 1 1
      osmd-extended
  2. 30 1
      src/helpers/customMusicScore.ts

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit 765141b814bf94bf9b810a09f966c40af18014c9
+Subproject commit bf0f802779ba6dacf1c64191c4c427bf47121d97

+ 30 - 1
src/helpers/customMusicScore.ts

@@ -160,7 +160,8 @@ export const resetGivenFormate = () => {
 // 谱面优化
 export const resetFormate = () => {
 	container.value = document.getElementById('scrollContainer')
-	if (state.extStyleConfigJson || !container.value) return;
+	// if (state.extStyleConfigJson || !container.value) return;
+	if (!container.value) return;
 	const stafflines: SVGAElement[] = Array.from((container.value as HTMLElement).querySelectorAll(".staffline"));
 	const baseStep = 4; // 两个元素相间,的间距
 	const musicalDistance = 28; // 音阶与第一条线谱的间距,默认设置为28
@@ -178,6 +179,8 @@ export const resetFormate = () => {
 		const rects: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure > .vf-stave rect[fill=none]"));
 		const staveSection: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure .vf-staveSection"));
 		const paths: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure > .vf-stave path"));
+		const dotModifiers: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure .vf-stopDot"));
+
 		// 获取第一个线谱的y轴坐标
 		const firstLinePathY = paths[0]?.getBBox().y || 0
 		// 反复标记 和 小节碰撞
@@ -307,6 +310,13 @@ export const resetFormate = () => {
 				label.textContent = labelText.replace('#','♯')
 			}
 		});
+		dotModifiers.forEach((group: any) => {
+			if (state.musicRenderType === 'fixedTone') {
+				group.setAttribute('transform', 'translate(3,-12)')
+			} else {
+				group.setAttribute('transform', 'translate(3,-7)')
+			}
+		});
 		const vftextBottom = Array.from(staffline.querySelectorAll(".vf-text > text")).filter((n: any) => n.getBBox().y > stafflineCenter);
 		const vflineBottom = Array.from(staffline.querySelectorAll(".vf-line")).filter((n: any) => n.getBBox().y > stafflineCenter);
 		// 去重
@@ -420,6 +430,25 @@ export const resetFormate = () => {
 				}
 			});
 		});
+
+		// 同一行内,多个飞线碰撞
+		for (let index = 0; index < vfcurve.length; index++) {
+			let nextIndex = index + 1;
+			const cur = vfcurve[index];
+			let next = vfcurve[nextIndex];
+			let checkDone = false;
+			while (nextIndex <= vfcurve.length - 1 && !checkDone) {
+				let result = collisionDetection(cur, next);
+				if (result.isCollision) {
+					checkDone = true;
+					next.style.transform = `translateY(-12px)`;
+				} else {
+					nextIndex = nextIndex + 1;
+					next = vfcurve[nextIndex];
+				}
+			}
+		};
+
 	}
 
 	// setTimeout(() => this.resetGlobalText());