API Docs for: 1.4.4
Show:

ukeGeeks.tabs Class

Tablature renderer -- reads tab data and draws canvas elements. Creates "packed" versions of the tabs, including a "key line" that's comprised only of '-' and '*' -- the asterisks denoting where a dot will eventually be placed.

Constructor

ukeGeeks.tabs

()

Methods

drawLabels

(
  • ctx
  • pos
  • settings
)
Void private

Adds the string letters on the left-side of the canvas, before the tablature string lines

Parameters:

  • ctx CanvasContext

    Handle to active canvas context

  • pos XyPos

    JSON (x,y) position

  • settings SettingsObj

Returns:

Void:

drawMeasure

(
  • ctx
  • pos
  • settings
  • heavy
)
Void private

Draws a vertical "measure" demarcation line

Parameters:

  • ctx CanvasContext

    Handle to active canvas context

  • pos XyPos

    JSON (x,y) position

  • settings SettingsObj
  • heavy Bool

    if TRUE hevy line

Returns:

Void:

drawNotes

(
  • ctx
  • pos
  • tabs
  • settings
  • lineWidth
)
Void private

Loop over the normalized tabs emitting the dots/fingers on the passed in canvase

Parameters:

  • ctx CanvasContext

    Handle to active canvas context

  • pos XyPos

    JSON (x,y) position

  • tabs Array

    Array of normalized string data -- space (character) or int (fret number)

  • settings SettingsObj
  • lineWidth Int

    Length in pixels (used only when line ends with a measure mark)

Returns:

Void:

drawStaff

(
  • ctx
  • pos
  • length
  • settings
)
Voie private

Create the staff -- really the four tablature strings

Parameters:

  • ctx CanvasContext

    Handle to active canvas context

  • pos XyPos

    JSON (x,y) position

  • length Int

    Length in pixels

  • settings SettingsObj

Returns:

Voie:

getFretNumbers

(
  • ukeStrings
)
Void private

Finds the frets in used for each line. In other words, ignoring spacers ("-" or "|") this returns arrays of numbers, the frets in use, for each line.

Parameters:

  • ukeStrings Array

Returns:

Void:

getGuideLine

(
  • symbols
  • minLength
)
Void private

OK, having created symbolic representations for the lines in earlier steps here we go through and "merge" them into a single, master "guide" -- saying "somewhere on this beat you'll pluck (or not) one note". This normalized guide will be the master for the next step.

Parameters:

  • symbols Undefined
  • minLength Int

Returns:

Void:

getMinLineLength

(
  • ukeStrings
)
Void private

Run through all of the strings (array) and return the length of the shortest one. would prefer the max length, but then I'd need to pad the shorter ones and ... well, it's complicated. this gets a TODO: get max!

Parameters:

  • ukeStrings Array

Returns:

Void:

getPackedLines

(
  • frets
  • symbols
  • guide
  • minLength
)
Void private

Using the packed "guide" line we loop over the strings, rebuilding each string with either a space, measure marker, or the note -- as an integer! Now the frets are the same regardless of whether they are single or double digit numbers: a "12" occupies no more horizontal space than a "5".

Parameters:

  • frets Undefined
  • symbols Undefined
  • guide Undefined
  • minLength Int

Returns:

Void:

getSymbols

(
  • ukeStrings
)
Void private

Returns array of the strings with placeholders instead of the numbers. This helps us pack because "12" and "7" now occupy the same space horizontally.

Parameters:

  • ukeStrings Array

Returns:

Void:

getWidth

(
  • tabs
  • labelOffset
  • isTruncate
)
Int private

Parameters:

  • tabs 2Darray
  • labelOffset Int
  • isTruncate Bool

    If TRUE returns the length of the line, allowing for a terminating "|" character, othwrwise, it's for canvas width

Returns:

Int:

init

() Void public

Again this is a constructor replacement

Returns:

Void:

loadBlocks

(
  • text
  • outElement
)
Void

Parameters:

  • text String

    Block of text that contains one or more tablature blocks

  • outElement String or DOM

    Either: (string) the Id to a DOM element, or DOM element handle where the canvas/converted text will be placed.

Returns:

Void:

readTabs

(
  • ukeStrings
)
2-dimentional array private

This is insanely long, insanely kludgy, but, insanely, it works. This will read break a block of text into four lines (the ukulele strings), then find which frets are used by each. Then, the hard part, pack un-needed dashes. Once it's done that a 2-dimentional array (strings X frets) is created and returned.

Parameters:

  • ukeStrings Array

    Block of tablbabure to be parsed

Returns:

2-dimentional array:

redraw

(
  • inTabs
  • outElement
)
Void

Parameters:

  • inTabs String or array

    Block of text or four element array containing tablbature to be parsed

  • outElement String or DOM

    Either: (string) the Id to a DOM element, or DOM element handle where the canvas/converted text will be placed.

Returns:

Void:

replace

(
  • h
)
Void public

Races through all <pre> tags within h, any with the CSS class of "ugsTabs" will be replaced with the canvas element.

Parameters:

  • h DOM-element

Returns:

Void:

stripStringLabels

(
  • ukeStrings
)
Void private

Processes ukeStrings stripping the first character from each line

Parameters:

  • ukeStrings Array

Returns:

Void:

Properties

LAST_STRING_NAME

String private

(Constant) Last String Name (Note), as above, on Ukulele is a "G". Here for other instruments.

NUM_STRINGS

Int private

(Constant) Number of Strings (dashed lines of tablature notation) expected. (For now a constant -- ukueleles "always" have four). Making a variable to help support port for other instruments.

tab_settings

JSON private

alias for external Settings dependencies (helps with complression, too)