OpenSheetMusicDisplay
    Preparing search index...

    Class VexFlowMusicSheetDrawer

    Draw a [[GraphicalMusicSheet]] (through the .drawSheet method)

    The drawing is implemented with a top-down approach, starting from a music sheet, going through pages, systems, staffs... ... and ending in notes, beams, accidentals and other symbols. It's worth to say, that this class just draws the symbols and graphical elements, using the positions that have been computed before. But in any case, some of these previous positioning algorithms need the sizes of the concrete symbols (NoteHeads, sharps, flats, keys...). Therefore, there are some static functions on the 'Bounding Boxes' section used to compute these symbol boxes at the beginning for the later use in positioning algorithms.

    This class also includes the resizing and positioning of the symbols due to user interaction like zooming or panning.

    Hierarchy (View Summary)

    Index
    bottomLineVisible: boolean = false
    drawableBoundingBoxElement: string = "None"
    drawingParameters: DrawingParameters
    graphicalMusicSheet: GraphicalMusicSheet
    LazyDrawFromXUnits: number = Number.NEGATIVE_INFINITY

    Lazy horizontal rendering (RenderSingleHorizontalStaffline): draw only graphical objects whose right edge x (in OSMD units) lies in (LazyDrawFromXUnits, LazyDrawToXUnits] -- the measures and spanning elements that first entered the drawn frontier this batch. ±Infinity (default) draws everything. Set by drawPage() for each system from LazyDrawSystemWindows; reset after.

    LazyDrawSystemsFromIndex: number = -1

    Lazy rendering: when >= 0, drawPage() draws only the systems whose index, counted through the systems of all pages, is within [LazyDrawSystemsFromIndex, LazyDrawSystemsToIndexExcl), leaving the already-drawn systems above untouched in the shared backends. -1 (default) draws every system. Set by OpenSheetMusicDisplay.renderAppend() before each appended batch; reset to -1 after.

    LazyDrawSystemsToIndexExcl: number = Number.POSITIVE_INFINITY
    LazyDrawSystemWindows: Map<MusicSystem, { fromX: number; toX: number }> = undefined

    Lazy horizontal rendering: when set, drawPage() draws only the systems in this map, each with its own draw x-window (see LazyDrawFromXUnits): a batch can reach several systems, e.g. after forced system breaks. Set by OpenSheetMusicDisplay.renderAppendGrowingHorizontal() per batch; reset after.

    LazyDrawToXUnits: number = Number.POSITIVE_INFINITY
    LazyForcePageLabels: boolean = false

    Lazy horizontal rendering: when true, drawLabel() ignores the x-window gate. Scoped (set/restored) to the page-label loop in drawPage(), since those labels span the full page width and must all be drawn even though their left edges lie behind the final batch's frontier, and to the labels of a measure's staff entries (see VexFlowMusicSheetDrawer.drawMeasure()), which are drawn with their measure.

    LazySkipPageLabels: boolean = false

    Lazy horizontal rendering: when true, drawPage() skips the page-level labels (title/credits) and the bounding boxes (see drawableBoundingBoxElement). They are drawn once, on the final batch, when the page is drawn to its full width.

    midiPlaybackAvailable: boolean
    skyLineVisible: boolean = false
    splitScreenLineColor: number
    textMeasurer: ITextMeasurer
    • Adds a class naming what a drawn element shows (e.g. "osmd-slur") to the SVG group it was drawn into, next to the class naming its shape (e.g. vf-curve), so that CSS and code can find e.g. all slurs. Labels get theirs from GraphicalLabel.SVGClass (see drawLabel()); the drawer names slurs (osmd-slur), the lines of wedges (osmd-wedge), the dashed lines after texts like "cresc. - - - -" (osmd-expression-dashes), lyric extender lines (osmd-extender) and the strokes of tremolos between notes and buzz rolls (osmd-tremolo).

      Parameters

      • node: Node

        the group, undefined if nothing was drawn, e.g. with the canvas backend

      • className: string

        the class

      Returns void

    • Clears what was drawn (the backends), and releases the drawn sheet and its pages, which the drawer only needs while drawing: their graphical objects reference the drawn SVG elements, so they would keep the whole rendering in memory. drawSheet() sets them again.

      Returns void

    • Draws the lyric lines (extenders, e.g. "dich___") of a staff line. They are positioned relative to the staff line (see MusicSheetCalculator.calculateLyricExtend()), because the staff lines are spaced vertically only after the lyrics are positioned. They are drawn at their absolute position without changing them, so that drawing the laid-out sheet again (e.g. in an incremental render) draws them at the same position.

      Parameters

      • lyricLines: GraphicalLine[]

        the lyric lines of the staff line

      • staffLine: StaffLine

        the staff line the lyric lines are positioned relative to

      Returns void

    • 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.

      Parameters

      Returns Node

    • Draws the strokes ("tremolo beams") of tremolos between two notes in this measure, e.g. two alternating half notes with 3 strokes between them, often seen in orchestral string parts. (Vexflow doesn't support these tremolos, so we draw them ourselves here.) Also updates the SkyLine/BottomLine where the strokes exceed it. Not where a note isn't drawn (see Note.isVisible()): the strokes are left out with it, like those of a single-note tremolo, which Vexflow draws in the style of its notehead (transparent then).

      Parameters

      Returns void

    • Gets the id of an SVG element that is drawn for a measure, but outside the measure's group (see GraphicalMeasure.getSVGGElement()), unique in the sheet's drawing: "osmd-", the kind of element, the measure's index in Sheet.SourceMeasures, "-", its staff's index in Sheet.Staves and "-" the element's number among those of its kind in the measure, all counted from 0, the indices as in the measure's own id (see GraphicalMeasure.getSVGGElementId()): "osmd-trem11-1-0" is the first tremolo stroke drawn with the 12th measure of the second staff.

      Parameters

      • kind: string

        "trem" for the strokes of a tremolo between two notes (drawn with the measure of the second note), "buzz" for a buzz roll

      • measure: GraphicalMeasure

        the measure the element is drawn with

      • numberInMeasure: number

        the element's number among those of its kind in the measure, from 0, in the order they are drawn

      Returns string

    • Gets the id of the SVG group a staffline is drawn into (g.osmd-staffline), unique in the sheet's drawing: "osmd-staffline", its system's index (MusicSystem.Id, counted from 0 through the pages), "-" and its staff's index in Sheet.Staves (from 0, as in the measures' ids, see GraphicalMeasure.getSVGGElementId()): "osmd-staffline3-1" is the second staff of the 4th system. Lazy horizontal rendering (renderNext() with RenderSingleHorizontalStaffline) draws a staffline into a group per batch: the first one, which starts the staffline, has the id.

      Parameters

      Returns string

    • Lazy horizontal rendering: whether an object with this bounding box falls in the current draw x-window (its right edge first entered the drawn frontier this batch). True when not lazy-horizontal.

      Parameters

      • rightXUnits: number

      Returns boolean

    • Lazy horizontal rendering: whether to draw the once-only system elements (instrument braces and group brackets at the left edge, and the sky and bottom lines of the stafflines, see skyLineVisible). True for non-lazy and for a system's first lazy-horizontal batch, which owns its left edge (LazyDrawFromXUnits is -Infinity); false for continuation batches, so a system's brace isn't redrawn on top of itself every batch. (Vertical lazy keeps the x-window at ±Infinity and draws each system's brace once via the per-system gate, so this stays true there.)

      Returns boolean

    • Lazy rendering: whether drawPage() draws the system with the given index (see LazyDrawSystemsFromIndex).

      Parameters

      • systemIndex: number

        the index of the system, counted through the systems of all pages

      Returns boolean

      true if the system is in the draw range of the batch, or if the render isn't lazy

    • Renders a Label to the screen (e.g. Title, composer..)

      Parameters

      • graphicalLabel: GraphicalLabel

        holds the label string, the text height in units and the font parameters

      • layer: number

        is the current rendering layer. There are many layers on top of each other to which can be rendered. Not needed for now.

      • bitmapWidth: number

        Not needed for now.

      • bitmapHeight: number

        Not needed for now.

      • fontHeightInPixel: number
      • screenPosition: PointF2D

        the position of the lower left corner of the text in screen coordinates

      Returns Node

    • Renders a rectangle with the given style to the screen. It is given in screen coordinates.

      Parameters

      • rectangle: RectangleF2D

        the rect in screen coordinates

      • layer: number

        is the current rendering layer. There are many layers on top of each other to which can be rendered. Not needed for now.

      • styleId: number

        the style id

      • colorHex: string
      • alpha: number

        alpha value between 0 and 1

      Returns Node

    • Sets the id of the SVG group a drawn element was drawn into, e.g. "osmd-trem11-1-0" for a tremolo stroke drawn with DrawPath(), which would add VexFlow's prefix (vf-) to an id given to it.

      Parameters

      • node: Node

        the group, undefined if nothing was drawn, e.g. with the canvas backend

      • id: string

        the id, unique in the sheet's drawing

      Returns void