Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GraceTabNote

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

Optional glyph

glyph?: any

keyProps

keyProps: KeyProps[]

keys

keys: string[]

render_options

render_options: { annotation_spacing: number; draw?: boolean; draw_dots?: boolean; draw_stem?: boolean; draw_stem_through_stave?: boolean; extend_left?: number; extend_right?: number; font: string; glyph_font_scale: number; glyph_font_size?: number; scale: number; stroke_px: number; y_shift: number }

Type declaration

  • annotation_spacing: number
  • Optional draw?: boolean
  • Optional draw_dots?: boolean
  • Optional draw_stem?: boolean
  • Optional draw_stem_through_stave?: boolean
  • Optional extend_left?: number
  • Optional extend_right?: number
  • font: string
  • glyph_font_scale: number
  • Optional glyph_font_size?: number
  • scale: number
  • stroke_px: number
  • y_shift: number

Optional stem

stem?: Stem

Optional stem_direction

stem_direction?: number

Static TEXT_FONT

TEXT_FONT: Required<FontInfo> = ...

Default font for text. This is not related to music engraving. Instead, see Flow.setMusicFont(...fontNames) to customize the font for musical symbols placed on the score.

Accessors

font

  • get font(): string
  • set font(f: string): void
  • Returns the CSS compatible font string.

    Returns string

  • Provide a CSS compatible font string (e.g., 'bold 16px Arial').

    Parameters

    • f: string

    Returns void

fontInfo

  • Return a copy of the current FontInfo object.

    Returns Required<FontInfo>

  • Return a copy of the current FontInfo object.

    Parameters

    Returns void

fontSize

  • get fontSize(): string
  • set fontSize(size: string | number): void
  • The size is 1) a string of the form '10pt' or '16px', compatible with the CSS font-size property. or 2) a number, which is interpreted as a point size (i.e. 12 == '12pt').

    Returns string

    a CSS font-size string (e.g., '18pt', '12px', '1em').

  • The size is 1) a string of the form '10pt' or '16px', compatible with the CSS font-size property. or 2) a number, which is interpreted as a point size (i.e. 12 == '12pt').

    Parameters

    • size: string | number

    Returns void

fontSizeInPixels

  • get fontSizeInPixels(): number
  • Returns number

    the font size in px.

fontSizeInPoints

  • get fontSizeInPoints(): number
  • Returns number

    the font size in pt.

fontStyle

  • get fontStyle(): string
  • set fontStyle(style: string): void
  • Returns string

    a CSS font-style string (e.g., 'italic').

  • Parameters

    • style: string

    Returns void

    a CSS font-style string (e.g., 'italic').

fontWeight

  • get fontWeight(): string
  • set fontWeight(weight: string | number): void
  • Returns string

    a CSS font-weight string (e.g., 'bold'). As in CSS, font-weight is always returned as a string, even if it was set as a number.

  • Parameters

    • weight: string | number

    Returns void

    a CSS font-weight string (e.g., 'bold'). As in CSS, font-weight is always returned as a string, even if it was set as a number.

postFormatted

  • get postFormatted(): boolean
  • set postFormatted(value: boolean): void
  • Set postformatted status.

    Returns boolean

  • Set postformatted status.

    Parameters

    • value: boolean

    Returns void

preFormatted

  • get preFormatted(): boolean
  • set preFormatted(value: boolean): void
  • Set preformatted status.

    Returns boolean

  • Set preformatted status.

    Parameters

    • value: boolean

    Returns void

Static CATEGORY

  • get CATEGORY(): string
  • Returns string

Methods

addChildElement

addClass

  • Add a class label (An element can have multiple class labels).

    Parameters

    • className: string

    Returns GraceTabNote

addModifier

addStroke

addToModifierContext

applyStyle

applyTickMultiplier

  • applyTickMultiplier(numerator: number, denominator: number): void

buildFlag

  • buildFlag(category?: string): void

buildStem

checkBeam

checkContext

checkModifierContext

checkStave

checkStem

checkTickContext

draw

  • draw(): void
  • Draw an element.

    Returns void

drawFlag

  • drawFlag(): void

drawModifiers

  • drawModifiers(): void

drawPositions

  • drawPositions(): void

drawStem

drawStemThrough

  • drawStemThrough(): void

drawWithStyle

  • drawWithStyle(): void
  • Draw the element and all its sub-elements (ie.: Modifiers in a Stave) with the element style.

    Returns void

getAbsoluteX

  • getAbsoluteX(): number
  • Get the absolute X position of this note's tick context. This excludes x_shift, so you'll need to factor it in if you're looking for the post-formatted x-position.

    Returns number

getAttribute

  • getAttribute(name: string): any

getAttributes

getBaseCustomNoteHeadGlyph

getBeam

  • getBeam(): undefined | Beam

getBeamCount

  • getBeamCount(): number

getBoundingBox

getCategory

  • getCategory(): string

getCenterGlyphX

  • getCenterGlyphX(): number

getCenterXShift

  • getCenterXShift(): number

getContext

getDuration

  • getDuration(): string

getFirstDotPx

  • getFirstDotPx(): number

getFont

  • getFont(): string

getFontSize

  • getFontSize(): string
  • Returns string

    a CSS font-size string (e.g., '18pt', '12px', '1em'). See Element.fontSizeInPixels or Element.fontSizeInPoints if you need to get a number for calculation purposes.

getFormatterMetrics

getGlyph

  • getGlyph(): any
  • Get the glyph associated with this note.

    Returns any

getGlyphWidth

  • getGlyphWidth(): number

getIntrinsicTicks

  • getIntrinsicTicks(): number

getKeyProps

getKeys

  • getKeys(): string[]

getLeftDisplacedHeadPx

  • getLeftDisplacedHeadPx(): number

getLeftParenthesisPx

  • getLeftParenthesisPx(index: number): number

getLineForRest

  • getLineForRest(): number

getLineNumber

  • getLineNumber(isTopNote?: boolean): number
  • Get the stave line number for the note.

    Parameters

    • Optional isTopNote: boolean

    Returns number

getMetrics

getModifierContext

getModifierStartXY

  • getModifierStartXY(position: number, index: number): { x: number; y: number }
  • Get the coordinates for where modifiers begin.

    Parameters

    • position: number
    • index: number

    Returns { x: number; y: number }

    • x: number
    • y: number

getModifiers

getModifiersByType

  • getModifiersByType(type: string): Modifier[]

getNoteType

  • getNoteType(): string

getPlayNote

  • getPlayNote(): undefined | Note
  • Get the play note, which is arbitrary data that can be used by an audio player.

    Returns undefined | Note

getPositions

getRightDisplacedHeadPx

  • getRightDisplacedHeadPx(): number

getRightParenthesisPx

  • getRightParenthesisPx(index: number): number

getSVGElement

  • getSVGElement(suffix?: string): undefined | SVGElement
  • Return associated SVGElement.

    Parameters

    • suffix: string = ''

    Returns undefined | SVGElement

getStave

  • getStave(): undefined | Stave

getStem

  • getStem(): undefined | Stem

getStemDirection

  • getStemDirection(): number

getStemExtension

  • getStemExtension(): number

getStemExtents

  • getStemExtents(): { baseY: number; topY: number }
  • Get the top and bottom y values of the stem.

    Returns { baseY: number; topY: number }

    • baseY: number
    • topY: number

getStemLength

  • getStemLength(): number

getStemMinimumLength

  • getStemMinimumLength(): number

getStemX

  • getStemX(): number

getStemY

  • getStemY(): number

getStyle

getTickContext

getTickMultiplier

getTicks

getTieLeftX

  • getTieLeftX(): number
  • Get the x coordinate to the left of the note.

    Returns number

getTieRightX

  • getTieRightX(): number
  • Get the x coordinate to the right of the note.

    Returns number

getTuplet

  • getTuplet(): undefined | Tuplet

getTupletStack

getVoice

getWidth

  • getWidth(): number
  • Get width of note. Used by the formatter for positioning.

    Returns number

getX

  • getX(): number
  • Get x position of this tick context.

    Returns number

getXShift

  • getXShift(): number
  • Get the x displaced pixels of the note.

    Returns number

getYForBottomText

  • getYForBottomText(textLine: number): number
  • Gets the y value for the bottom modifiers at a specific textLine.

    Parameters

    • textLine: number

    Returns number

getYForTopText

  • getYForTopText(textLine: number): number
  • Gets the y value for the top modifiers at a specific textLine.

    Parameters

    • textLine: number

    Returns number

getYs

  • getYs(): number[]
  • Get Y positions for this note. Each Y value is associated with an individual pitch/key within the note/chord.

    Returns number[]

greatestString

  • greatestString(): number

hasBeam

  • hasBeam(): boolean

hasClass

  • hasClass(className: string): boolean
  • Check if it has a class label (An element can have multiple class labels).

    Parameters

    • className: string

    Returns boolean

hasFlag

  • hasFlag(): boolean

hasStem

  • hasStem(): boolean

isCenterAligned

  • isCenterAligned(): boolean

isDotted

  • isDotted(): boolean

isRendered

  • isRendered(): boolean

isRest

  • isRest(): boolean
  • Returns boolean

    true if this note is a type of rest.

    Rests don't have pitches, but take up space in the score. Subclasses should override this default implementation.

leastString

  • leastString(): number

onRegister

postFormat

preFormat

  • preFormat(): void

removeClass

reset

resetFont

  • resetFont(): void
  • Reset the text font to the style indicated by the static TEXT_FONT property. Subclasses can call this to initialize textFont for the first time.

    Returns void

resetTuplet

  • Reset the specific Tuplet if this is not provided, all tuplets are reset. Remove any prior tuplets from the tick calculation and reset the intrinsic tick value.

    Parameters

    Returns GraceTabNote

restoreStyle

setAttribute

setBeam

setCenterAlignment

setCenterXShift

setContext

setDuration

setFont

  • setFont(font?: string | FontInfo, size?: string | number, weight?: string | number, style?: string): GraceTabNote
  • Set the element's font family, size, weight, style (e.g., Arial, 10pt, bold, italic).

    Parameters

    • Optional font: string | FontInfo

      is 1) a FontInfo object or 2) a string formatted as CSS font shorthand (e.g., 'bold 10pt Arial') or 3) a string representing the font family (at least one of size, weight, or style must also be provided).

    • Optional size: string | number

      a string specifying the font size and unit (e.g., '16pt'), or a number (the unit is assumed to be 'pt').

    • Optional weight: string | number

      is a string (e.g., 'bold', 'normal') or a number (100, 200, ... 900).

    • Optional style: string

      is a string (e.g., 'italic', 'normal'). If no arguments are provided, then the font is set to the default font. Each Element subclass may specify its own default by overriding the static TEXT_FONT property.

    Returns GraceTabNote

setFontSize

  • Change the font size, while keeping everything else the same.

    Parameters

    • Optional size: string | number

    Returns GraceTabNote

setGhost

setGroupStyle

setIgnoreTicks

setIntrinsicTicks

  • setIntrinsicTicks(intrinsicTicks: number): void

setLeftDisplacedHeadPx

setModifierContext

setPlayNote

setRendered

setRightDisplacedHeadPx

setStave

setStem

setStemDirection

setStemLength

setStyle

  • Set the element style used to render.

    Example:

    element.setStyle({ fillStyle: 'red', strokeStyle: 'red' });
    element.draw();

    Note: If the element draws additional sub-elements (ie.: Modifiers in a Stave), the style can be applied to all of them by means of the context:

    element.setStyle({ fillStyle: 'red', strokeStyle: 'red' });
    element.getContext().setFillStyle('red');
    element.getContext().setStrokeStyle('red');
    element.draw();

    or using drawWithStyle:

    element.setStyle({ fillStyle: 'red', strokeStyle: 'red' });
    element.drawWithStyle();

    Parameters

    Returns GraceTabNote

setTickContext

setTuplet

setVoice

setWidth

  • setWidth(width: number): void
  • Set width of note. Used by the formatter for positioning.

    Parameters

    • width: number

    Returns void

setXShift

setYs

  • Set Y positions for this note. Each Y value is associated with an individual pitch/key within the note/chord.

    Parameters

    • ys: number[]

    Returns GraceTabNote

shouldIgnoreTicks

  • shouldIgnoreTicks(): boolean
  • True if this note has no duration (e.g., bar notes, spacers, etc.).

    Returns boolean

updateWidth

  • updateWidth(): void

Static plotMetrics