opensheetmusicdisplay
Version:
An open source JavaScript engine for displaying MusicXML based on VexFlow.
115 lines (114 loc) • 6.11 kB
TypeScript
import { MusicSheetDrawer } from "../MusicSheetDrawer";
import { RectangleF2D } from "../../../Common/DataObjects/RectangleF2D";
import { VexFlowMeasure } from "./VexFlowMeasure";
import { PointF2D } from "../../../Common/DataObjects/PointF2D";
import { GraphicalLabel } from "../GraphicalLabel";
import { MusicSystem } from "../MusicSystem";
import { GraphicalObject } from "../GraphicalObject";
import { GraphicalStaffEntry } from "../GraphicalStaffEntry";
import { VexFlowBackend } from "./VexFlowBackend";
import { StaffLine } from "../StaffLine";
import { GraphicalInstantaneousDynamicExpression } from "../GraphicalInstantaneousDynamicExpression";
import { VexFlowContinuousDynamicExpression } from "./VexFlowContinuousDynamicExpression";
import { DrawingParameters } from "../DrawingParameters";
import { GraphicalMusicPage } from "../GraphicalMusicPage";
import { GraphicalMusicSheet } from "../GraphicalMusicSheet";
/**
* This is a global constant which denotes the height in pixels of the space between two lines of the stave
* (when zoom = 1.0)
* @type number
*/
export declare const unitInPixels: number;
export declare class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
private backend;
private backends;
private zoom;
private pageIdx;
constructor(drawingParameters?: DrawingParameters);
get Backends(): VexFlowBackend[];
drawSheet(graphicalMusicSheet: GraphicalMusicSheet): void;
protected drawPage(page: GraphicalMusicPage): void;
clear(): void;
setZoom(zoom: number): void;
/**
* Converts a distance from unit to pixel space.
* @param unitDistance the distance in units
* @returns {number} the distance in pixels
*/
calculatePixelDistance(unitDistance: number): number;
protected drawStaffLine(staffLine: StaffLine): void;
private drawSlurs;
private drawGlissandi;
private drawGlissando;
private drawSlur;
protected drawMeasure(measure: VexFlowMeasure): void;
protected drawBuzzRolls(staffEntry: GraphicalStaffEntry, newBuzzRollId: any): number;
/** Draws a line in the current backend. Only usable while pages are drawn sequentially, because backend reference is updated in that process.
* To add your own lines after rendering, use DrawOverlayLine.
*/
protected drawLine(start: PointF2D, stop: PointF2D, color?: string, lineWidth?: number): Node;
/** Lets a user/developer draw an overlay line on the score. Use this instead of drawLine, which is for OSMD internally only.
* The MusicPage has to be specified, because each page and Vexflow backend has its own relative coordinates.
* (the AbsolutePosition of a GraphicalNote is relative to its backend)
* To get a MusicPage, use GraphicalNote.ParentMusicPage.
*/
DrawOverlayLine(start: PointF2D, stop: PointF2D, musicPage: GraphicalMusicPage, color?: string, lineWidth?: number, id?: string): Node;
DrawPath(inputPoints: PointF2D[], musicPage: GraphicalMusicPage, fill?: boolean, id?: string): Node;
protected drawSkyLine(staffline: StaffLine): void;
protected drawBottomLine(staffline: StaffLine): void;
/**
* Draw a line with a width and start point in a chosen color (used for skyline/bottom line debugging) from
* a simple array
* @param line numeric array. 0 marks the base line. Direction given by sign. Dimensions in units
* @param startPosition Start position in units
* @param width Max line width in units
* @param color Color to paint in. Default is red
*/
private drawSampledLine;
private drawStaffEntry;
/**
* Draw all lyrics to the canvas
* @param lyricEntries Array of lyric entries to be drawn
* @param layer Number of the layer that the lyrics should be drawn in
*/
private drawLyrics;
protected drawInstrumentBrace(brace: GraphicalObject, system: MusicSystem): void;
protected drawGroupBracket(bracket: GraphicalObject, system: MusicSystem): void;
protected drawOctaveShifts(staffLine: StaffLine): void;
protected drawPedals(staffLine: StaffLine): void;
protected drawWavyLines(staffLine: StaffLine): void;
protected drawExpressions(staffline: StaffLine): void;
protected drawInstantaneousDynamic(instantaneousDynamic: GraphicalInstantaneousDynamicExpression): void;
protected drawContinuousDynamic(graphicalExpression: VexFlowContinuousDynamicExpression): void;
/**
* Renders a Label to the screen (e.g. Title, composer..)
* @param graphicalLabel holds the label string, the text height in units and the font parameters
* @param layer is the current rendering layer. There are many layers on top of each other to which can be rendered. Not needed for now.
* @param bitmapWidth Not needed for now.
* @param bitmapHeight Not needed for now.
* @param heightInPixel the height of the text in screen coordinates
* @param screenPosition the position of the lower left corner of the text in screen coordinates
*/
protected renderLabel(graphicalLabel: GraphicalLabel, layer: number, bitmapWidth: number, bitmapHeight: number, fontHeightInPixel: number, screenPosition: PointF2D): Node;
/**
* Renders a rectangle with the given style to the screen.
* It is given in screen coordinates.
* @param rectangle the rect in screen coordinates
* @param layer is the current rendering layer. There are many layers on top of each other to which can be rendered. Not needed for now.
* @param styleId the style id
* @param alpha alpha value between 0 and 1
*/
protected renderRectangle(rectangle: RectangleF2D, layer: number, styleId: number, colorHex: string, alpha: number): Node;
/**
* Converts a point from unit to pixel space.
* @param point
* @returns {PointF2D}
*/
protected applyScreenTransformation(point: PointF2D): PointF2D;
/**
* Converts a rectangle from unit to pixel space.
* @param rectangle
* @returns {RectangleF2D}
*/
protected applyScreenTransformationForRect(rectangle: RectangleF2D): RectangleF2D;
}