termtab-0.1.0.0: TUI guitar tablature and score editor
Safe HaskellNone
LanguageGHC2021

Termtab.Graphics.Notation

Description

Rasterized standard-notation renderer.

Composes the visible measures of a track into a single RGBA image: a five-line staff, a treble clef, bar lines, and Bravura noteheads/rests placed at their staff positions. This is the image that the Kitty/Sixel backends blit above the tab grid.

Beat x-positions are derived from the same beatColumnWidth column math the tab uses, so notation and tab stay column-aligned. The mapping from columns to pixels (nlColWidthPx) is a layout parameter tuned against the terminal's real cell size when the renderer is wired into the UI (Phase 0).

Note: this imports beatColumnWidth from the tab widget for now; that column helper is a candidate for extraction into a shared layout module later.

Synopsis

Documentation

data NotationLayout Source #

Pixel geometry for the notation image.

Constructors

NotationLayout 

Fields

  • nlStepPx :: Int

    Vertical pixels between adjacent staff positions (line - space).

  • nlColWidthPx :: Int

    Pixels per tab column (governs horizontal scale + tab alignment).

  • nlLabelCols :: Int

    Columns reserved at the left for the clef (matches the tab's label column).

  • nlLedgerAbove :: Int

    Extra staff positions of headroom above the top line.

  • nlLedgerBelow :: Int

    Extra staff positions of headroom below the bottom line.

  • nlMarginPx :: Int

    Top/bottom padding in pixels.

defaultLayout :: NotationLayout Source #

The layout used everywhere the UI renders notation images (see Termtab.UI.NotationGraphics). A distinct NotationLayout could be built for a different pixel density, but nothing in the codebase currently does so.

renderNotationImage :: GlyphFont -> NotationLayout -> PixelRGBA8 -> Int -> Instrument -> [(MeasureIndex, [Beat], Measure)] -> IO (Image PixelRGBA8) Source #

Render the visible measures of a track to an RGBA notation image.

The background is fully transparent and all ink (staff, clef, bar lines, noteheads) is drawn in ink — pass the terminal's foreground color so the notation adopts the user's theme (see Termtab.Graphics.TermColor). Glyph anti-aliasing is preserved via the alpha channel.

totalColumns :: NotationLayout -> Int -> [(MeasureIndex, [Beat], Measure)] -> Int Source #

Total tab columns across all visible measures (label + measures + bar lines).