|
@@ -192,14 +192,14 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
|
|
|
/** 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 = "#FF0000FF", lineWidth: number = 0.2): void {
|
|
|
+ protected drawLine(start: PointF2D, stop: PointF2D, color: string = "#FF0000FF", lineWidth: number = 0.2): Node {
|
|
|
// TODO maybe the backend should be given as an argument here as well, otherwise this can't be used after rendering of multiple pages is done.
|
|
|
start = this.applyScreenTransformation(start);
|
|
|
stop = this.applyScreenTransformation(stop);
|
|
|
/*if (!this.backend) {
|
|
|
this.backend = this.backends[0];
|
|
|
}*/
|
|
|
- this.backend.renderLine(start, stop, color, lineWidth * unitInPixels);
|
|
|
+ return this.backend.renderLine(start, stop, color, lineWidth * unitInPixels);
|
|
|
}
|
|
|
|
|
|
/** Lets a user/developer draw an overlay line on the score. Use this instead of drawLine, which is for OSMD internally only.
|
|
@@ -208,7 +208,7 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
|
|
|
* To get a MusicPage, use GraphicalNote.ParentMusicPage.
|
|
|
*/
|
|
|
public DrawOverlayLine(start: PointF2D, stop: PointF2D, musicPage: GraphicalMusicPage,
|
|
|
- color: string = "#FF0000FF", lineWidth: number = 0.2): void {
|
|
|
+ color: string = "#FF0000FF", lineWidth: number = 0.2): Node {
|
|
|
if (!musicPage.PageNumber || musicPage.PageNumber > this.backends.length || musicPage.PageNumber < 1) {
|
|
|
console.log("VexFlowMusicSheetDrawer.drawOverlayLine: invalid page number / music page number doesn't correspond to an existing backend.");
|
|
|
return;
|
|
@@ -218,7 +218,7 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
|
|
|
|
|
|
start = this.applyScreenTransformation(start);
|
|
|
stop = this.applyScreenTransformation(stop);
|
|
|
- backendToUse.renderLine(start, stop, color, lineWidth * unitInPixels);
|
|
|
+ return backendToUse.renderLine(start, stop, color, lineWidth * unitInPixels);
|
|
|
}
|
|
|
|
|
|
protected drawSkyLine(staffline: StaffLine): void {
|
|
@@ -403,10 +403,11 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
|
|
|
* @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): void {
|
|
|
+ bitmapHeight: number, fontHeightInPixel: number, screenPosition: PointF2D): Node[] {
|
|
|
if (!graphicalLabel.Label.print) {
|
|
|
- return;
|
|
|
+ return [];
|
|
|
}
|
|
|
+ const nodes: Node[] = [];
|
|
|
const height: number = graphicalLabel.Label.fontHeight * unitInPixels;
|
|
|
const { font } = graphicalLabel.Label;
|
|
|
let color: string;
|
|
@@ -428,13 +429,16 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
|
|
|
const currLine: {text: string, xOffset: number, width: number} = graphicalLabel.TextLines[i];
|
|
|
const xOffsetInPixel: number = this.calculatePixelDistance(currLine.xOffset);
|
|
|
const linePosition: PointF2D = new PointF2D(screenPosition.x + xOffsetInPixel, screenPosition.y);
|
|
|
- this.backend.renderText(height, fontStyle, font, currLine.text, fontHeightInPixel, linePosition, color, graphicalLabel.Label.fontFamily);
|
|
|
+ nodes.push(
|
|
|
+ this.backend.renderText(height, fontStyle, font, currLine.text, fontHeightInPixel, linePosition, color, graphicalLabel.Label.fontFamily)
|
|
|
+ );
|
|
|
screenPosition.y = screenPosition.y + fontHeightInPixel;
|
|
|
if (graphicalLabel.TextLines.length > 1) {
|
|
|
screenPosition.y += this.rules.SpacingBetweenTextLines;
|
|
|
}
|
|
|
}
|
|
|
// font currently unused, replaced by fontFamily
|
|
|
+ return nodes;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -445,8 +449,8 @@ export class VexFlowMusicSheetDrawer extends MusicSheetDrawer {
|
|
|
* @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): void {
|
|
|
- this.backend.renderRectangle(rectangle, styleId, colorHex, alpha);
|
|
|
+ protected renderRectangle(rectangle: RectangleF2D, layer: number, styleId: number, colorHex: string, alpha: number): Node {
|
|
|
+ return this.backend.renderRectangle(rectangle, styleId, colorHex, alpha);
|
|
|
}
|
|
|
|
|
|
/**
|