MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / ScoreRenderer

Class ScoreRenderer

packages/alphatab/src/rendering/ScoreRenderer.ts:24–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 * @public
23 */
24export class ScoreRenderer implements IScoreRenderer {
25 private _currentLayoutMode: LayoutMode = LayoutMode.Page;
26 private _currentRenderEngine: string | null = null;
27 private _renderedTracks: Track[] | null = null;
28
29 public canvas: ICanvas | null = null;
30 public score: Score | null = null;
31 public tracks: Track[] | null = null;
32 /**
33 * @internal
34 */
35 public layout: ScoreLayout | null = null;
36 public settings: Settings;
37 public boundsLookup: BoundsLookup | null = null;
38 public width: number = 0;
39
40 /**
41 * Initializes a new instance of the {@link ScoreRenderer} class.
42 * @param settings The settings to use for rendering.
43 */
44 public constructor(settings: Settings) {
45 this.settings = settings;
46 this._recreateCanvas();
47 this._recreateLayout();
48 }
49
50 public destroy(): void {
51 this.score = null;
52 this.canvas?.destroy();
53 this.canvas = null;
54 this.layout = null;
55 this.boundsLookup = null;
56 this.tracks = null;
57 }
58
59 private _recreateCanvas(): boolean {
60 if (this._currentRenderEngine !== this.settings.core.engine) {
61 this.canvas?.destroy();
62 this.canvas = Environment.getRenderEngineFactory(this.settings.core.engine).createCanvas();
63 this._currentRenderEngine = this.settings.core.engine;
64 return true;
65 }
66 return false;
67 }
68
69 private _recreateLayout(): boolean {
70 if (!this.layout || this._currentLayoutMode !== this.settings.display.layoutMode) {
71 this.layout = Environment.getLayoutEngineFactory(this.settings.display.layoutMode).createLayout(this);
72 this._currentLayoutMode = this.settings.display.layoutMode;
73 return true;
74 }
75 return false;
76 }
77
78 public renderScore(score: Score | null, trackIndexes: number[] | null, renderHints?: RenderHints): void {
79 try {
80 this.score = score;
81 let tracks: Track[] | null = null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected