import Vex from "vexflow" ; import { FontStyles } from "../../../Common/Enums/FontStyles" ; import { Fonts } from "../../../Common/Enums/Fonts" ; import { RectangleF2D } from "../../../Common/DataObjects/RectangleF2D" ; import { PointF2D } from "../../../Common/DataObjects/PointF2D" ; import { BackendType } from "../../../OpenSheetMusicDisplay/OSMDOptions" ; import { GraphicalMusicPage } from "../GraphicalMusicPage" ; import { EngravingRules } from "../EngravingRules" ; export class VexFlowBackends { public static CANVAS : 0 ; public static RAPHAEL : 1 ; public static SVG : 2 ; public static VML : 3 ; } export abstract class VexFlowBackend { /** The GraphicalMusicPage the backend is drawing from. Each backend only renders one GraphicalMusicPage, to which the coordinates are relative. */ public graphicalMusicPage : GraphicalMusicPage ; protected rules : EngravingRules ; public width : number ; public height : number ; public abstract initialize ( container , zoom ) ; public getInnerElement ( ) { return this . inner ; } public getCanvas ( ) { return this . canvas ; } public abstract getCanvasSize ( ) ; public getRenderElement ( ) { let renderingHtmlElement = this . canvas ; if ( this . getVexflowBackendType ( ) === Vex . Flow . Renderer . Backends . CANVAS ) { renderingHtmlElement = this . inner ; } return renderingHtmlElement ; } public getRenderer ( ) { return this . renderer ; } public removeAllChildrenFromContainer ( container ) { while ( container . children . length !== 0 ) { container . removeChild ( container . children . item ( 0 ) ) ; } } public removeFromContainer ( container ) { const htmlElementToRemove = this . getRenderElement ( ) ; for ( let i = 0 ; i < container . children . length ; i ++ ) { if ( container . children . item ( i ) === htmlElementToRemove ) { container . removeChild ( htmlElementToRemove ) ; break ; } } } public abstract getContext ( ) ; public abstract scale ( k ) ; public resize ( width , height ) { this . renderer . resize ( width , height ) ; this . width = width ; this . height = height ; } public abstract clear ( ) ; public abstract translate ( x , y ) ; public abstract renderText ( fontHeight , fontStyle , font , text , heightInPixel , screenPosition , color ? , fontFamily ? ) ; param rectangle param layer param styleId param alpha public abstract renderRectangle ( rectangle , styleId , colorHex , alpha ) ; public abstract renderLine ( start , stop , color , lineWidth ) ; public abstract renderCurve ( points ) ; public abstract getVexflowBackendType ( ) ; /** The general type of backend: Canvas or SVG.
     * This is not used for now (only VexflowBackendType used), but it may be useful when we don't want to use a Vexflow class.
     */ public abstract getOSMDBackendType ( ) ; protected renderer : Vex . Flow . Renderer ; protected inner : HTMLElement ; protected canvas : HTMLElement ; }