瀏覽代碼

feat(GraphicalNote): add osmd.rules.GNote(note) (#660) to get GraphicalNote from Note

also see PR #559
sschmid 4 年之前
父節點
當前提交
d1d12c91ca
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      src/MusicalScore/Graphical/EngravingRules.ts

+ 7 - 1
src/MusicalScore/Graphical/EngravingRules.ts

@@ -585,8 +585,14 @@ export class EngravingRules {
         this.NoteToGraphicalNoteMapObjectCount++;
         this.NoteToGraphicalNoteMapObjectCount++;
     }
     }
 
 
-    public clearObjects(): void {
+    public GNote(note: Note): GraphicalNote {
+        return GraphicalNote.FromNote(note, this);
+    }
+
+    /** This should be done before a new sheet is loaded, not each re-render (otherwise the map would end empty). */
+    public clearMusicSheetObjects(): void {
         this.NoteToGraphicalNoteMap = new Dictionary<number, GraphicalNote>();
         this.NoteToGraphicalNoteMap = new Dictionary<number, GraphicalNote>();
+        this.NoteToGraphicalNoteMapObjectCount = 0;
     }
     }
 
 
     public setChordSymbolLabelText(key: ChordSymbolEnum, value: string): void {
     public setChordSymbolLabelText(key: ChordSymbolEnum, value: string): void {