Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GlyphNote

Hierarchy

Index

Constructors

Properties

glyphProps: GlyphProps
keyProps: KeyProps[]
keys: string[]
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
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

  • 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

  • Return a copy of the current FontInfo object.

    Returns Required<FontInfo>

  • Return a copy of the current FontInfo object.

    Parameters

    Returns void

  • 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

  • get fontSizeInPixels(): number
  • Returns number

    the font size in px.

  • get fontSizeInPoints(): number
  • Returns number

    the font size in pt.

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

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

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

    Returns boolean

  • Set postformatted status.

    Parameters

    • value: boolean

    Returns void

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

    Returns boolean

  • Set preformatted status.

    Parameters

    • value: boolean

    Returns void

  • get CATEGORY(): string
  • Returns string

Methods

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

    Parameters

    • className: string

    Returns GlyphNote

  • Attach a modifier to this note.

    Parameters

    • modifier: Modifier

      the Modifier to add.

    • index: number = 0

      of the key to modify.

    Returns GlyphNote

    this

  • applyTickMultiplier(numerator: number, denominator: number): void
  • Apply a tick multiplier.

    Parameters

    • numerator: number
    • denominator: number

    Returns void

  • draw(): void
  • Draw an element.

    Returns void

  • drawModifiers(): void
  • Returns void

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

    Returns void

  • 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(name: string): any
  • Return an attribute.

    Parameters

    • name: string

    Returns any

  • getBeam(): undefined | Beam
  • getCategory(): string
  • getCenterXShift(): number
  • getDuration(): string
  • getFirstDotPx(): number
  • getFont(): string
  • 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.

  • getGlyph(): any
  • deprecated

    Use getGlyphProps() instead.

    Returns any

  • getGlyphWidth(): number
  • getIntrinsicTicks(): number
  • getKeys(): string[]
  • getLeftDisplacedHeadPx(): number
  • getLeftParenthesisPx(index: number): number
  • getLineForRest(): number
  • getLineNumber(isTopNote?: boolean): number
  • Get the stave line number for the note.

    Parameters

    • Optional isTopNote: boolean

    Returns number

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

    Parameters

    • Optional position: number
    • Optional index: number
    • Optional options: any

    Returns { x: number; y: number }

    • x: number
    • y: number
  • getModifiersByType(type: string): Modifier[]
  • getNoteType(): string
  • getPlayNote(): undefined | Note
  • Get the play note, which is arbitrary data that can be used by an audio player.

    Returns undefined | Note

  • getRightDisplacedHeadPx(): number
  • getRightParenthesisPx(index: number): number
  • getSVGElement(suffix?: string): undefined | SVGElement
  • Return associated SVGElement.

    Parameters

    • suffix: string = ''

    Returns undefined | SVGElement

  • getStave(): undefined | Stave
  • getStemDirection(): number
  • getStemExtents(): Record<string, number>
  • Get the top and bottom y values of the stem.

    Returns Record<string, number>

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

    Returns number

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

    Returns number

  • getTuplet(): undefined | Tuplet
  • Return the voice that this note belongs in.

    Returns Voice

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

    Returns number

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

    Returns number

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

    Returns number

  • getYForTopText(text_line: number): number
  • Get the Y position of the space above the stave onto which text can be rendered.

    Parameters

    • text_line: number

    Returns number

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

    Returns number[]

  • hasBeam(): boolean
  • Check it has a beam.

    Returns boolean

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

    Parameters

    • className: string

    Returns boolean

  • hasStem(): boolean
  • Accessor to hasStem.

    Returns boolean

  • isCenterAligned(): boolean
  • isDotted(): boolean
  • Accessor to isDotted.

    Returns boolean

  • isRendered(): boolean
  • Return the rendered status.

    Returns boolean

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

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

    Parameters

    • className: string

    Returns GlyphNote

  • Reset the Tickable, this function will be overloaded.

    Returns GlyphNote

  • 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

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

  • setAttribute(name: string, value: undefined | string): GlyphNote
  • setCenterAlignment(align_center: boolean): GlyphNote
  • setCenterXShift(centerXShift: number): GlyphNote
  • setFont(font?: string | FontInfo, size?: string | number, weight?: string | number, style?: string): GlyphNote
  • 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 GlyphNote

  • setFontSize(size?: string | number): GlyphNote
  • Change the font size, while keeping everything else the same.

    Parameters

    • Optional size: string | number

    Returns GlyphNote

  • setIntrinsicTicks(intrinsicTicks: number): void
  • Set the intrinsic ticks.

    Parameters

    • intrinsicTicks: number

    Returns void

  • Set the play note, which is arbitrary data that can be used by an audio player.

    Parameters

    Returns GlyphNote

  • setRightDisplacedHeadPx(x: number): GlyphNote
  • 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 GlyphNote

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

    Parameters

    • width: number

    Returns void

  • Displace note by x pixels. Used by the formatter.

    Parameters

    • x: number

    Returns GlyphNote

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

    Parameters

    • ys: number[]

    Returns GlyphNote

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

    Returns boolean