@nodelyra/not-angka 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +38 -2
- package/THIRD_PARTY.md +24 -0
- package/dist/esm/cursor/activeChord.d.ts +12 -0
- package/dist/esm/cursor/activeChord.js +36 -0
- package/dist/esm/cursor/beatDot.d.ts +30 -0
- package/dist/esm/cursor/beatDot.js +49 -0
- package/dist/esm/cursor/drawnTop.d.ts +9 -0
- package/dist/esm/cursor/drawnTop.js +16 -0
- package/dist/esm/cursor/pageBoxes.d.ts +28 -0
- package/dist/esm/cursor/pageBoxes.js +75 -0
- package/dist/esm/cursor/playbackCursor.d.ts +25 -0
- package/dist/esm/cursor/playbackCursor.js +42 -0
- package/dist/esm/cursor/playingStyle.d.ts +16 -0
- package/dist/esm/cursor/playingStyle.js +34 -0
- package/dist/esm/cursor/playingTones.d.ts +8 -0
- package/dist/esm/cursor/playingTones.js +16 -0
- package/dist/esm/cursor/target.d.ts +47 -0
- package/dist/esm/cursor/target.js +63 -0
- package/dist/esm/export/pageText.d.ts +8 -0
- package/dist/esm/export/pageText.js +80 -0
- package/dist/esm/export/svgExport.d.ts +46 -0
- package/dist/esm/export/svgExport.js +88 -0
- package/dist/esm/geometry/metrics.d.ts +42 -0
- package/dist/esm/geometry/metrics.js +52 -0
- package/dist/esm/geometry/pageSetup.d.ts +61 -0
- package/dist/esm/geometry/pageSetup.js +85 -0
- package/dist/esm/geometry/paper.d.ts +16 -0
- package/dist/esm/geometry/paper.js +16 -0
- package/dist/esm/index.d.ts +35 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/layout/LayoutEngine.d.ts +64 -0
- package/dist/esm/layout/LayoutEngine.js +92 -0
- package/dist/esm/layout/arcs.d.ts +20 -0
- package/dist/esm/layout/arcs.js +53 -0
- package/dist/esm/layout/barlineShapes.d.ts +52 -0
- package/dist/esm/layout/barlineShapes.js +71 -0
- package/dist/esm/layout/directions.d.ts +48 -0
- package/dist/esm/layout/directions.js +122 -0
- package/dist/esm/layout/elementBoxes.d.ts +17 -0
- package/dist/esm/layout/elementBoxes.js +72 -0
- package/dist/esm/layout/floating.d.ts +29 -0
- package/dist/esm/layout/floating.js +39 -0
- package/dist/esm/layout/keyMarks.d.ts +26 -0
- package/dist/esm/layout/keyMarks.js +30 -0
- package/dist/esm/layout/lyricAlign.d.ts +6 -0
- package/dist/esm/layout/lyricAlign.js +15 -0
- package/dist/esm/layout/lyricWords.d.ts +13 -0
- package/dist/esm/layout/lyricWords.js +27 -0
- package/dist/esm/layout/lyricsLayout.d.ts +55 -0
- package/dist/esm/layout/lyricsLayout.js +122 -0
- package/dist/esm/layout/markings.d.ts +97 -0
- package/dist/esm/layout/markings.js +150 -0
- package/dist/esm/layout/measurePlan.d.ts +74 -0
- package/dist/esm/layout/measurePlan.js +232 -0
- package/dist/esm/layout/measureSegments.d.ts +24 -0
- package/dist/esm/layout/measureSegments.js +64 -0
- package/dist/esm/layout/notationMetrics.d.ts +110 -0
- package/dist/esm/layout/notationMetrics.js +122 -0
- package/dist/esm/layout/systemBreaking.d.ts +59 -0
- package/dist/esm/layout/systemBreaking.js +137 -0
- package/dist/esm/layout/systemLayout.d.ts +138 -0
- package/dist/esm/layout/systemLayout.js +266 -0
- package/dist/esm/layout/tupletSpacing.d.ts +9 -0
- package/dist/esm/layout/tupletSpacing.js +33 -0
- package/dist/esm/layout/tuplets.d.ts +30 -0
- package/dist/esm/layout/tuplets.js +39 -0
- package/dist/esm/model/hiddenParts.d.ts +23 -0
- package/dist/esm/model/hiddenParts.js +39 -0
- package/dist/esm/model/locate.d.ts +18 -0
- package/dist/esm/model/locate.js +31 -0
- package/dist/esm/model/lowVoices.d.ts +9 -0
- package/dist/esm/model/lowVoices.js +20 -0
- package/dist/esm/model/partColors.d.ts +13 -0
- package/dist/esm/model/partColors.js +10 -0
- package/dist/esm/model/partSpan.d.ts +25 -0
- package/dist/esm/model/partSpan.js +49 -0
- package/dist/esm/model/rowPresence.d.ts +14 -0
- package/dist/esm/model/rowPresence.js +19 -0
- package/dist/esm/model/sharedLyrics.d.ts +23 -0
- package/dist/esm/model/sharedLyrics.js +68 -0
- package/dist/esm/model/textBars.d.ts +12 -0
- package/dist/esm/model/textBars.js +21 -0
- package/dist/esm/model/tickRanges.d.ts +22 -0
- package/dist/esm/model/tickRanges.js +34 -0
- package/dist/esm/model/unisons.d.ts +69 -0
- package/dist/esm/model/unisons.js +181 -0
- package/dist/esm/notation/chords.d.ts +12 -0
- package/dist/esm/notation/chords.js +29 -0
- package/dist/esm/notation/elision.d.ts +24 -0
- package/dist/esm/notation/elision.js +47 -0
- package/dist/esm/notation/keys.d.ts +50 -0
- package/dist/esm/notation/keys.js +59 -0
- package/dist/esm/notation/lyricAlign.d.ts +7 -0
- package/dist/esm/notation/lyricAlign.js +15 -0
- package/dist/esm/notation/navigation.d.ts +3 -0
- package/dist/esm/notation/navigation.js +5 -0
- package/dist/esm/notation/pitch.d.ts +39 -0
- package/dist/esm/notation/pitch.js +74 -0
- package/dist/esm/notation/pitchName.d.ts +2 -0
- package/dist/esm/notation/pitchName.js +3 -0
- package/dist/esm/notation/profile.d.ts +35 -0
- package/dist/esm/notation/profile.js +16 -0
- package/dist/esm/notation/rhythm.d.ts +59 -0
- package/dist/esm/notation/rhythm.js +116 -0
- package/dist/esm/notation/time.d.ts +98 -0
- package/dist/esm/notation/time.js +85 -0
- package/dist/esm/performance/compilePerformance.d.ts +7 -0
- package/dist/esm/performance/compilePerformance.js +8 -0
- package/dist/esm/performance/dynamics.d.ts +6 -0
- package/dist/esm/performance/dynamics.js +78 -0
- package/dist/esm/performance/model.d.ts +56 -0
- package/dist/esm/performance/model.js +1 -0
- package/dist/esm/performance/playOrder.d.ts +16 -0
- package/dist/esm/performance/playOrder.js +64 -0
- package/dist/esm/performance/readScore.d.ts +4 -0
- package/dist/esm/performance/readScore.js +58 -0
- package/dist/esm/performance/timeline.d.ts +10 -0
- package/dist/esm/performance/timeline.js +144 -0
- package/dist/esm/playback/audioOutput.d.ts +46 -0
- package/dist/esm/playback/audioOutput.js +106 -0
- package/dist/esm/playback/clock.d.ts +16 -0
- package/dist/esm/playback/clock.js +44 -0
- package/dist/esm/playback/createPlayerStore.d.ts +79 -0
- package/dist/esm/playback/createPlayerStore.js +135 -0
- package/dist/esm/playback/cues.d.ts +34 -0
- package/dist/esm/playback/cues.js +52 -0
- package/dist/esm/playback/errors.d.ts +6 -0
- package/dist/esm/playback/errors.js +6 -0
- package/dist/esm/playback/metronome.d.ts +13 -0
- package/dist/esm/playback/metronome.js +15 -0
- package/dist/esm/playback/mix.d.ts +9 -0
- package/dist/esm/playback/mix.js +8 -0
- package/dist/esm/playback/pass.d.ts +27 -0
- package/dist/esm/playback/pass.js +36 -0
- package/dist/esm/playback/schedule.d.ts +7 -0
- package/dist/esm/playback/schedule.js +12 -0
- package/dist/esm/playback/session.d.ts +46 -0
- package/dist/esm/playback/session.js +107 -0
- package/dist/esm/playback/source.d.ts +6 -0
- package/dist/esm/playback/source.js +1 -0
- package/dist/esm/playback/start.d.ts +28 -0
- package/dist/esm/playback/start.js +38 -0
- package/dist/esm/playback/timing.d.ts +14 -0
- package/dist/esm/playback/timing.js +11 -0
- package/dist/esm/playback/types.d.ts +60 -0
- package/dist/esm/playback/types.js +1 -0
- package/dist/esm/playback/volume.d.ts +12 -0
- package/dist/esm/playback/volume.js +8 -0
- package/dist/esm/player/ControlBar.d.ts +22 -0
- package/dist/esm/player/ControlBar.js +77 -0
- package/dist/esm/player/CursorPainter.d.ts +17 -0
- package/dist/esm/player/CursorPainter.js +53 -0
- package/dist/esm/player/InfoLine.d.ts +6 -0
- package/dist/esm/player/InfoLine.js +23 -0
- package/dist/esm/player/PageView.d.ts +10 -0
- package/dist/esm/player/PageView.js +16 -0
- package/dist/esm/player/actions.d.ts +24 -0
- package/dist/esm/player/actions.js +26 -0
- package/dist/esm/player/balanceSystems.d.ts +8 -0
- package/dist/esm/player/balanceSystems.js +18 -0
- package/dist/esm/player/createExcerptPlayer.d.ts +33 -0
- package/dist/esm/player/createExcerptPlayer.js +169 -0
- package/dist/esm/player/createScorePlayer.d.ts +24 -0
- package/dist/esm/player/createScorePlayer.js +118 -0
- package/dist/esm/player/dom.d.ts +6 -0
- package/dist/esm/player/dom.js +15 -0
- package/dist/esm/player/embeddedFonts.d.ts +1 -0
- package/dist/esm/player/embeddedFonts.js +3 -0
- package/dist/esm/player/exclusivePlayback.d.ts +10 -0
- package/dist/esm/player/exclusivePlayback.js +13 -0
- package/dist/esm/player/followCursor.d.ts +5 -0
- package/dist/esm/player/followCursor.js +16 -0
- package/dist/esm/player/icons.d.ts +7 -0
- package/dist/esm/player/icons.js +9 -0
- package/dist/esm/player/injectFonts.d.ts +8 -0
- package/dist/esm/player/injectFonts.js +19 -0
- package/dist/esm/player/loadExcerpt.d.ts +21 -0
- package/dist/esm/player/loadExcerpt.js +123 -0
- package/dist/esm/player/loadScore.d.ts +12 -0
- package/dist/esm/player/loadScore.js +12 -0
- package/dist/esm/player/mountExcerpts.d.ts +30 -0
- package/dist/esm/player/mountExcerpts.js +109 -0
- package/dist/esm/player/playhead.d.ts +12 -0
- package/dist/esm/player/playhead.js +14 -0
- package/dist/esm/player/shadowStyles.d.ts +5 -0
- package/dist/esm/player/shadowStyles.js +23 -0
- package/dist/esm/player/staticSvg.d.ts +7 -0
- package/dist/esm/player/staticSvg.js +10 -0
- package/dist/esm/player/styles.d.ts +28 -0
- package/dist/esm/player/styles.js +98 -0
- package/dist/esm/player/theme.d.ts +8 -0
- package/dist/esm/player/theme.js +13 -0
- package/dist/esm/player/types.d.ts +76 -0
- package/dist/esm/player/types.js +12 -0
- package/dist/esm/rendering/SystemRenderer.d.ts +6 -0
- package/dist/esm/rendering/SystemRenderer.js +58 -0
- package/dist/esm/rendering/accidentalRenderer.d.ts +4 -0
- package/dist/esm/rendering/accidentalRenderer.js +41 -0
- package/dist/esm/rendering/arcRenderer.d.ts +9 -0
- package/dist/esm/rendering/arcRenderer.js +32 -0
- package/dist/esm/rendering/barlineRenderer.d.ts +8 -0
- package/dist/esm/rendering/barlineRenderer.js +59 -0
- package/dist/esm/rendering/directionRenderer.d.ts +4 -0
- package/dist/esm/rendering/directionRenderer.js +50 -0
- package/dist/esm/rendering/durationLineRenderer.d.ts +9 -0
- package/dist/esm/rendering/durationLineRenderer.js +27 -0
- package/dist/esm/rendering/dynamicGlyphs.d.ts +25 -0
- package/dist/esm/rendering/dynamicGlyphs.js +56 -0
- package/dist/esm/rendering/frameRenderer.d.ts +17 -0
- package/dist/esm/rendering/frameRenderer.js +252 -0
- package/dist/esm/rendering/keyMarkRenderer.d.ts +8 -0
- package/dist/esm/rendering/keyMarkRenderer.js +57 -0
- package/dist/esm/rendering/lyricsRenderer.d.ts +4 -0
- package/dist/esm/rendering/lyricsRenderer.js +44 -0
- package/dist/esm/rendering/primitives.d.ts +64 -0
- package/dist/esm/rendering/primitives.js +1 -0
- package/dist/esm/rendering/sliceRenderer.d.ts +19 -0
- package/dist/esm/rendering/sliceRenderer.js +79 -0
- package/dist/esm/rendering/textBarRenderer.d.ts +8 -0
- package/dist/esm/rendering/textBarRenderer.js +28 -0
- package/dist/esm/rendering/tupletRenderer.d.ts +7 -0
- package/dist/esm/rendering/tupletRenderer.js +42 -0
- package/dist/esm/schema/normalize.d.ts +14 -0
- package/dist/esm/schema/normalize.js +123 -0
- package/dist/esm/schema/pageMeta.d.ts +11 -0
- package/dist/esm/schema/pageMeta.js +1 -0
- package/dist/esm/schema/scoreJson.d.ts +59 -0
- package/dist/esm/schema/scoreJson.js +1 -0
- package/dist/esm/schema/scoreView.d.ts +16 -0
- package/dist/esm/schema/scoreView.js +24 -0
- package/dist/esm/schema/types.d.ts +339 -0
- package/dist/esm/schema/types.js +1 -0
- package/dist/esm/text/creditLines.d.ts +12 -0
- package/dist/esm/text/creditLines.js +11 -0
- package/dist/esm/text/fonts.d.ts +50 -0
- package/dist/esm/text/fonts.js +98 -0
- package/dist/esm/text/headerFooter.d.ts +13 -0
- package/dist/esm/text/headerFooter.js +21 -0
- package/dist/esm/text/textLines.d.ts +7 -0
- package/dist/esm/text/textLines.js +13 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -0
- package/dist/nodelyra-player.global.js +65 -0
- package/dist/nodelyra-player.global.js.map +1 -0
- package/dist/nodelyra-player.lite.global.js +63 -0
- package/dist/nodelyra-player.lite.global.js.map +1 -0
- package/examples/blog-excerpt.html +54 -0
- package/examples/twinkle.html +23 -0
- package/examples/twinkle.json +91 -0
- package/package.json +70 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BarlineType } from "../schema/types.js";
|
|
2
|
+
import { type RepeatStart } from "../layout/barlineShapes.js";
|
|
3
|
+
import type { MeasureBounds, Row } from "../layout/systemLayout.js";
|
|
4
|
+
import type { Primitive } from "./primitives.js";
|
|
5
|
+
/** The closing bar line of a measure on row `index`, and its repeat start if it has one. */
|
|
6
|
+
export declare function renderBarlines(rows: readonly Row[], index: number, bounds: MeasureBounds, barline: BarlineType, repeatStart: RepeatStart,
|
|
7
|
+
/** Run the closing bar line through lyrics too (it borders a text bar). */
|
|
8
|
+
throughLyrics?: boolean): Primitive[];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BARLINE_SHAPES, REPEAT_START_SHAPES } from "../layout/barlineShapes.js";
|
|
2
|
+
import { NOTATION } from "../layout/notationMetrics.js";
|
|
3
|
+
const DOT_R = 1.4;
|
|
4
|
+
/**
|
|
5
|
+
* A row's bar lines run from just above its digits to just below them, or, when the row has no
|
|
6
|
+
* lyrics (or the bar runs through lyrics), down to the next row's bar lines, so the parts' bar
|
|
7
|
+
* lines join as in the reference.
|
|
8
|
+
*/
|
|
9
|
+
function barSpan(rows, index, throughLyrics = false) {
|
|
10
|
+
const row = rows[index];
|
|
11
|
+
const next = rows[index + 1];
|
|
12
|
+
const top = row.noteY - NOTATION.barHalfHeight;
|
|
13
|
+
if (next && (throughLyrics || row.lyricLines === 0))
|
|
14
|
+
return { top, bottom: next.noteY - NOTATION.barHalfHeight };
|
|
15
|
+
return { top, bottom: row.noteY + NOTATION.barHalfHeight };
|
|
16
|
+
}
|
|
17
|
+
function draw(shape, x, rows, index, owner) {
|
|
18
|
+
const { top, bottom } = barSpan(rows, index, shape.throughLyrics);
|
|
19
|
+
const strokes = shape.strokes.map((s) => ({
|
|
20
|
+
kind: "line",
|
|
21
|
+
role: "barline",
|
|
22
|
+
owner,
|
|
23
|
+
x1: x + s.dx,
|
|
24
|
+
y1: top,
|
|
25
|
+
x2: x + s.dx,
|
|
26
|
+
y2: bottom,
|
|
27
|
+
width: s.width,
|
|
28
|
+
tone: "ink",
|
|
29
|
+
}));
|
|
30
|
+
const dots = shape.dots === undefined || index > 0 ? [] : repeatDots(x + shape.dots, rows, owner);
|
|
31
|
+
return [...strokes, ...dots];
|
|
32
|
+
}
|
|
33
|
+
/** The repeat sign's two dots, centred on the system's full bar height. */
|
|
34
|
+
function repeatDots(cx, rows, owner) {
|
|
35
|
+
const top = rows[0].noteY - NOTATION.barHalfHeight;
|
|
36
|
+
const bottom = rows[rows.length - 1].noteY + NOTATION.barHalfHeight;
|
|
37
|
+
const middle = (top + bottom) / 2;
|
|
38
|
+
return [-3.5, 3.5].map((dy) => ({
|
|
39
|
+
kind: "circle",
|
|
40
|
+
role: "repeat-dot",
|
|
41
|
+
owner,
|
|
42
|
+
cx,
|
|
43
|
+
cy: middle + dy,
|
|
44
|
+
r: DOT_R,
|
|
45
|
+
tone: "ink",
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
/** The closing bar line of a measure on row `index`, and its repeat start if it has one. */
|
|
49
|
+
export function renderBarlines(rows, index, bounds, barline, repeatStart,
|
|
50
|
+
/** Run the closing bar line through lyrics too (it borders a text bar). */
|
|
51
|
+
throughLyrics = false) {
|
|
52
|
+
const startShape = REPEAT_START_SHAPES[repeatStart];
|
|
53
|
+
const start = startShape
|
|
54
|
+
? draw(startShape, bounds.x + NOTATION.repeatStartWidth / 2, rows, index, bounds.measureId)
|
|
55
|
+
: [];
|
|
56
|
+
const shape = BARLINE_SHAPES[barline];
|
|
57
|
+
const closing = throughLyrics ? { ...shape, throughLyrics: true } : shape;
|
|
58
|
+
return [...start, ...draw(closing, bounds.barX, rows, index, bounds.measureId)];
|
|
59
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NOTATION } from "../layout/notationMetrics.js";
|
|
2
|
+
import { dynamicPath } from "./dynamicGlyphs.js";
|
|
3
|
+
/**
|
|
4
|
+
* One renderer per kind of direction (ADR 0011): dynamics as solid shapes of Times-style bold italic
|
|
5
|
+
* letters (no font needed) centred on their note,
|
|
6
|
+
* expressions italic from their note, hairpins as two lines that open (crescendo) or close
|
|
7
|
+
* (diminuendo). A hairpin part that goes on to the next system stays half open at that end.
|
|
8
|
+
*/
|
|
9
|
+
const DIRECTION_RENDERERS = {
|
|
10
|
+
// Drawn as strokes, not text: the same on every device, in print and in an exported SVG.
|
|
11
|
+
dynamic: (item, y) => [
|
|
12
|
+
{
|
|
13
|
+
kind: "path",
|
|
14
|
+
role: "dynamic",
|
|
15
|
+
owner: item.key,
|
|
16
|
+
d: dynamicPath(item.text, item.x, y, NOTATION.dynamicSize),
|
|
17
|
+
width: 0,
|
|
18
|
+
filled: true,
|
|
19
|
+
tone: "ink",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
text: (item, y) => [
|
|
23
|
+
{ kind: "text", role: "expression", owner: item.key, x: item.x, y, text: item.text, size: NOTATION.expressionSize, anchor: "start", font: "text", italic: true, tone: "ink" },
|
|
24
|
+
],
|
|
25
|
+
hairpin: (item, y) => {
|
|
26
|
+
const middle = y - NOTATION.dynamicSize * 0.23; // the middle of the dynamics' x-height
|
|
27
|
+
const half = NOTATION.hairpinHalf;
|
|
28
|
+
// Wide at the end of a crescendo, at the start of a diminuendo. Where a hairpin breaks across
|
|
29
|
+
// systems both parts are half open, so the wedge reads as one.
|
|
30
|
+
const [startWidth, endWidth] = item.shape === "cresc" ? [0, half] : [half, 0];
|
|
31
|
+
const startOpen = item.openStart ? half / 2 : startWidth;
|
|
32
|
+
const endOpen = item.openEnd ? half / 2 : endWidth;
|
|
33
|
+
const line = (sign) => ({
|
|
34
|
+
kind: "line",
|
|
35
|
+
role: "hairpin",
|
|
36
|
+
owner: item.key,
|
|
37
|
+
x1: item.x1,
|
|
38
|
+
y1: middle + sign * startOpen,
|
|
39
|
+
x2: item.x2,
|
|
40
|
+
y2: middle + sign * endOpen,
|
|
41
|
+
width: 0.9,
|
|
42
|
+
tone: "ink",
|
|
43
|
+
});
|
|
44
|
+
return [line(-1), line(1)];
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
/** Everything written in a system's direction band. */
|
|
48
|
+
export function renderDirections({ y, items }) {
|
|
49
|
+
return items.flatMap((item) => DIRECTION_RENDERERS[item.kind](item, y - item.lift));
|
|
50
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Row, RowMeasure } from "../layout/systemLayout.js";
|
|
2
|
+
import type { NotationProfile } from "../notation/profile.js";
|
|
3
|
+
import type { Primitive } from "./primitives.js";
|
|
4
|
+
/**
|
|
5
|
+
* The duration lines (numbered-notation beams) of one row's measure (PRD FR-030, FR-031, FR-034).
|
|
6
|
+
* Each beam group gets one line per level; deeper levels cover only their shorter pieces and are
|
|
7
|
+
* stacked under the longer line (between it and the digits), as in the reference score.
|
|
8
|
+
*/
|
|
9
|
+
export declare function renderDurationLines(row: Row, measure: RowMeasure, profile: NotationProfile): Primitive[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NOTATION } from "../layout/notationMetrics.js";
|
|
2
|
+
import { durationLines } from "../notation/rhythm.js";
|
|
3
|
+
/** Half the width a duration line reaches past the centre of its first and last piece. */
|
|
4
|
+
const REACH = 5;
|
|
5
|
+
/**
|
|
6
|
+
* The duration lines (numbered-notation beams) of one row's measure (PRD FR-030, FR-031, FR-034).
|
|
7
|
+
* Each beam group gets one line per level; deeper levels cover only their shorter pieces and are
|
|
8
|
+
* stacked under the longer line (between it and the digits), as in the reference score.
|
|
9
|
+
*/
|
|
10
|
+
export function renderDurationLines(row, measure, profile) {
|
|
11
|
+
const side = profile.durationLines === "above" ? -1 : 1;
|
|
12
|
+
return measure.groups.flatMap((group) => durationLines(measure.slices, group).map((line) => {
|
|
13
|
+
const y = row.noteY +
|
|
14
|
+
side * (NOTATION.durationLineOffset - (line.level - 1) * NOTATION.lineGap);
|
|
15
|
+
return {
|
|
16
|
+
kind: "line",
|
|
17
|
+
role: "duration-line",
|
|
18
|
+
owner: measure.slices[line.first].eventId,
|
|
19
|
+
x1: measure.slices[line.first].x - REACH,
|
|
20
|
+
y1: y,
|
|
21
|
+
x2: measure.slices[line.last].x + REACH,
|
|
22
|
+
y2: y,
|
|
23
|
+
width: 1,
|
|
24
|
+
tone: "ink",
|
|
25
|
+
};
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamics (p, m, f and their combinations) drawn as vector shapes, not text: they look the same
|
|
3
|
+
* on every device, in print and in an exported SVG, whatever fonts are installed.
|
|
4
|
+
*
|
|
5
|
+
* The letters are the outlines of Bold Italic Tinos (SIL Open Font License 1.1, see
|
|
6
|
+
* THIRD_PARTY.md), the open font with the same design and metrics as Times New Roman, so a dynamic
|
|
7
|
+
* reads as Times New Roman bold italic. Outlines are in font units (2048 to the em, y up, the
|
|
8
|
+
* baseline at 0) as `M`, `L`, `Q` and `Z` with absolute coordinates; `advance` is the pen's step
|
|
9
|
+
* to the next letter, `left` and `right` the ink's extent.
|
|
10
|
+
*/
|
|
11
|
+
import type { DynamicLevel } from "../schema/types.js";
|
|
12
|
+
/** How far the letters reach below the baseline (the tail of p and f) and above it (f), in ems. */
|
|
13
|
+
export declare const DESCENT_EM: number;
|
|
14
|
+
export declare const ASCENT_EM: number;
|
|
15
|
+
/** The width a dynamic takes, in layout px. */
|
|
16
|
+
export declare const dynamicWidth: (level: DynamicLevel, size: number) => number;
|
|
17
|
+
/** The box a dynamic is drawn in, centred on `x`, resting on the baseline `y`. */
|
|
18
|
+
export declare function dynamicBox(level: DynamicLevel, x: number, y: number, size: number): {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
};
|
|
24
|
+
/** SVG path data (a solid shape) of a dynamic centred on `x`, resting on the baseline `y`. */
|
|
25
|
+
export declare function dynamicPath(level: DynamicLevel, x: number, y: number, size: number): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const UNITS_PER_EM = 2048;
|
|
2
|
+
const LETTERS = {
|
|
3
|
+
p: {
|
|
4
|
+
d: "M962 631Q962 453 897 304Q832 154 714 67Q596 -20 449 -20Q363 -20 294 13L292 -16L280 -111L242 -347L402 -371L390 -436L-146 -436L-134 -371L-30 -347L184 855L85 880L97 940L442 940L436 802Q561 965 703 965Q820 965 891 875Q962 785 962 631ZM699 587Q699 692 668 752Q638 813 588 813Q520 813 420 680L322 127Q346 103 380 91Q413 79 438 79Q510 79 570 150Q631 220 665 340Q699 459 699 587Z",
|
|
5
|
+
advance: 1024,
|
|
6
|
+
left: -146,
|
|
7
|
+
right: 962,
|
|
8
|
+
},
|
|
9
|
+
m: {
|
|
10
|
+
d: "M1220 725Q1220 822 1148 822Q1113 822 1066 782Q1018 742 980 680Q943 618 933 563L834 0L567 0L669 569Q691 685 691 725Q691 822 617 822Q569 822 508 756Q447 689 411 594L305 0L39 0L187 849L98 874L111 940L439 940L436 772Q508 870 589 918Q670 965 770 965Q859 965 910 912Q960 860 961 767Q1102 965 1299 965Q1387 965 1439 910Q1491 854 1491 754Q1491 717 1474 622L1379 90L1495 66L1482 0L1096 0L1198 569Q1220 685 1220 725Z",
|
|
11
|
+
advance: 1593,
|
|
12
|
+
left: 39,
|
|
13
|
+
right: 1495,
|
|
14
|
+
},
|
|
15
|
+
// Tinos' f with the ball terminal and the hooked tail of Times New Roman's.
|
|
16
|
+
f: {
|
|
17
|
+
d: "M222 836L60 836L72 905L241 944L264 1066Q301 1264 408 1353Q515 1442 693 1442Q790 1442 850 1462Q960 1485 1015 1395Q1045 1295 960 1250Q880 1215 830 1275Q795 1318 740 1332Q710 1334 681 1332Q628 1332 595 1278Q562 1225 538 1098L509 940L715 940L697 836L491 836L297 -290Q280 -400 170 -430Q60 -455 -50 -400Q-130 -355 -135 -280Q-138 -215 -80 -212Q-30 -210 -22 -258Q-18 -290 -5 -320Z",
|
|
18
|
+
advance: 682,
|
|
19
|
+
left: -170,
|
|
20
|
+
right: 1045,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
/** How far the letters reach below the baseline (the tail of p and f) and above it (f), in ems. */
|
|
24
|
+
export const DESCENT_EM = 460 / UNITS_PER_EM;
|
|
25
|
+
export const ASCENT_EM = 1485 / UNITS_PER_EM;
|
|
26
|
+
const lettersOf = (level) => [...level].map((c) => LETTERS[c]);
|
|
27
|
+
/** The ink of a dynamic, in font units: from its first letter's left edge to its last letter's right. */
|
|
28
|
+
const extentOf = (letters) => {
|
|
29
|
+
const stepped = letters.slice(0, -1).reduce((sum, l) => sum + l.advance, 0);
|
|
30
|
+
return { left: letters[0].left, width: stepped + letters.at(-1).right - letters[0].left };
|
|
31
|
+
};
|
|
32
|
+
/** The width a dynamic takes, in layout px. */
|
|
33
|
+
export const dynamicWidth = (level, size) => (extentOf(lettersOf(level)).width / UNITS_PER_EM) * size;
|
|
34
|
+
/** The box a dynamic is drawn in, centred on `x`, resting on the baseline `y`. */
|
|
35
|
+
export function dynamicBox(level, x, y, size) {
|
|
36
|
+
const width = dynamicWidth(level, size);
|
|
37
|
+
return { x: x - width / 2, y: y - ASCENT_EM * size, width, height: (ASCENT_EM + DESCENT_EM) * size };
|
|
38
|
+
}
|
|
39
|
+
const round = (n) => Math.round(n * 100) / 100;
|
|
40
|
+
/** SVG path data (a solid shape) of a dynamic centred on `x`, resting on the baseline `y`. */
|
|
41
|
+
export function dynamicPath(level, x, y, size) {
|
|
42
|
+
const letters = lettersOf(level);
|
|
43
|
+
const scale = size / UNITS_PER_EM;
|
|
44
|
+
const { left, width } = extentOf(letters);
|
|
45
|
+
let pen = x - (width * scale) / 2 - left * scale; // where the first letter's origin goes
|
|
46
|
+
const parts = [];
|
|
47
|
+
for (const letter of letters) {
|
|
48
|
+
const at = pen;
|
|
49
|
+
parts.push(letter.d.replace(/([MLQ])([^MLQZ]*)/g, (_, command, numbers) => {
|
|
50
|
+
const pairs = numbers.trim().split(/[ ]+/).map(Number);
|
|
51
|
+
return command + pairs.map((n, i) => round(i % 2 === 0 ? at + n * scale : y - n * scale)).join(" ");
|
|
52
|
+
}));
|
|
53
|
+
pen += letter.advance * scale;
|
|
54
|
+
}
|
|
55
|
+
return parts.join("");
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type SystemMarkings } from "../layout/markings.js";
|
|
2
|
+
import type { SystemLayout } from "../layout/systemLayout.js";
|
|
3
|
+
import type { Primitive } from "./primitives.js";
|
|
4
|
+
/**
|
|
5
|
+
* Part labels (S., A., ...) and, in a score of more than one part, the bracket that joins the
|
|
6
|
+
* system (unless the page setup hides it: `bracket` false). A system with one row has it too: a
|
|
7
|
+
* solo line of a choir score (only the Soprano sings there), or one "SA." row of merged parts.
|
|
8
|
+
* Only a score of one part (a melody) goes without. `scoreParts`: how many parts the score shows.
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderFrame(system: SystemLayout, bracket?: boolean, scoreParts?: number): Primitive[];
|
|
11
|
+
/** 1 -> "I", 2 -> "II", 4 -> "IV" (volta numbers are small). */
|
|
12
|
+
export declare function toRoman(n: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Chord symbols, volta brackets with their numbers, section labels and the first measure's
|
|
15
|
+
* number. Brackets and labels sit above the chord band.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderMarkings(markings: SystemMarkings, headroom: number): Primitive[];
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { NOTATION, textWidth } from "../layout/notationMetrics.js";
|
|
2
|
+
import { chordCenter, KEY_CHANGE_SIZE, KEY_FRAME_PAD, LABEL_SIZE, TEMPO_MARK_SIZE } from "../layout/markings.js";
|
|
3
|
+
import { barlineEdges } from "../layout/barlineShapes.js";
|
|
4
|
+
/**
|
|
5
|
+
* Part labels (S., A., ...) and, in a score of more than one part, the bracket that joins the
|
|
6
|
+
* system (unless the page setup hides it: `bracket` false). A system with one row has it too: a
|
|
7
|
+
* solo line of a choir score (only the Soprano sings there), or one "SA." row of merged parts.
|
|
8
|
+
* Only a score of one part (a melody) goes without. `scoreParts`: how many parts the score shows.
|
|
9
|
+
*/
|
|
10
|
+
export function renderFrame(system, bracket = true, scoreParts = 1) {
|
|
11
|
+
const labels = system.rows.map((row) => ({
|
|
12
|
+
kind: "text",
|
|
13
|
+
role: "part-label",
|
|
14
|
+
owner: row.partId,
|
|
15
|
+
x: NOTATION.labelX,
|
|
16
|
+
y: row.noteY,
|
|
17
|
+
text: row.label,
|
|
18
|
+
size: NOTATION.labelSize,
|
|
19
|
+
anchor: "start",
|
|
20
|
+
font: "text",
|
|
21
|
+
bold: true,
|
|
22
|
+
tone: "ink",
|
|
23
|
+
}));
|
|
24
|
+
const parts = system.rows.reduce((sum, row) => sum + row.partCount, 0);
|
|
25
|
+
if (!bracket || Math.max(parts, scoreParts) < 2)
|
|
26
|
+
return labels;
|
|
27
|
+
const top = system.rows[0].noteY - NOTATION.barHalfHeight - 2;
|
|
28
|
+
const last = system.rows[system.rows.length - 1];
|
|
29
|
+
const bottom = last.y + last.height - last.gap;
|
|
30
|
+
return [...bracketShapes(top, bottom), ...labels];
|
|
31
|
+
}
|
|
32
|
+
/** Air between a key change frame and the bracket's top horn below it. */
|
|
33
|
+
const OVER_BRACKET_GAP = 5;
|
|
34
|
+
/**
|
|
35
|
+
* The centre line of a "1 = F" that opens a system: its frame sits just above the bracket's top
|
|
36
|
+
* horn (the first row's digits are `headroom + digitY` down; the bracket starts `barHalfHeight + 2`
|
|
37
|
+
* above them and its horn rises `hornRise + 1` more).
|
|
38
|
+
*/
|
|
39
|
+
const overBracketY = (headroom) => headroom + NOTATION.digitY - NOTATION.barHalfHeight - 2 - BRACKET.hornRise - 1 - OVER_BRACKET_GAP - KEY_FRAME_PAD.y - KEY_CHANGE_SIZE / 2;
|
|
40
|
+
/** Bracket proportions (px): the heavy bar, its horns, and the thin rule beside it. */
|
|
41
|
+
const BRACKET = { bar: 2.6, hornReach: 9.5, hornRise: 5, ruleGap: 1.4, rule: 0.8 };
|
|
42
|
+
/**
|
|
43
|
+
* The system bracket of the reference score: a heavy bar whose ends sweep out to the right in
|
|
44
|
+
* pointed horns, with a thin rule running alongside it on the inside.
|
|
45
|
+
*/
|
|
46
|
+
function bracketShapes(top, bottom) {
|
|
47
|
+
const x = NOTATION.bracketX;
|
|
48
|
+
const inner = x + BRACKET.bar;
|
|
49
|
+
const tip = x + BRACKET.hornReach;
|
|
50
|
+
const rise = BRACKET.hornRise;
|
|
51
|
+
const bar = {
|
|
52
|
+
kind: "path",
|
|
53
|
+
role: "bracket",
|
|
54
|
+
d: `M ${x} ${top} C ${x} ${top - rise} ${tip - 4} ${top - rise} ${tip} ${top - rise - 1} ` +
|
|
55
|
+
`C ${inner + 2} ${top - rise + 1} ${inner} ${top - 1} ${inner} ${top + 1} L ${inner} ${bottom - 1} ` +
|
|
56
|
+
`C ${inner} ${bottom + 1} ${inner + 2} ${bottom + rise - 1} ${tip} ${bottom + rise + 1} ` +
|
|
57
|
+
`C ${tip - 4} ${bottom + rise} ${x} ${bottom + rise} ${x} ${bottom} Z`,
|
|
58
|
+
width: 0,
|
|
59
|
+
filled: true,
|
|
60
|
+
tone: "ink",
|
|
61
|
+
};
|
|
62
|
+
const ruleX = inner + BRACKET.ruleGap + BRACKET.rule / 2;
|
|
63
|
+
const rule = {
|
|
64
|
+
kind: "line",
|
|
65
|
+
role: "bracket",
|
|
66
|
+
x1: ruleX,
|
|
67
|
+
y1: top,
|
|
68
|
+
x2: ruleX,
|
|
69
|
+
y2: bottom,
|
|
70
|
+
width: BRACKET.rule,
|
|
71
|
+
tone: "ink",
|
|
72
|
+
};
|
|
73
|
+
return [bar, rule];
|
|
74
|
+
}
|
|
75
|
+
const ROMAN = [
|
|
76
|
+
[10, "X"],
|
|
77
|
+
[9, "IX"],
|
|
78
|
+
[5, "V"],
|
|
79
|
+
[4, "IV"],
|
|
80
|
+
[1, "I"],
|
|
81
|
+
];
|
|
82
|
+
/** 1 -> "I", 2 -> "II", 4 -> "IV" (volta numbers are small). */
|
|
83
|
+
export function toRoman(n) {
|
|
84
|
+
let rest = n;
|
|
85
|
+
let out = "";
|
|
86
|
+
for (const [value, numeral] of ROMAN)
|
|
87
|
+
while (rest >= value) {
|
|
88
|
+
out += numeral;
|
|
89
|
+
rest -= value;
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Volta bracket proportions (px): the numeral's circle, the slanted ends, the air above bars. */
|
|
94
|
+
const SECTION_RULE_GAP = 6;
|
|
95
|
+
const VOLTA = { radius: NOTATION.voltaRadius, slant: 4, numberSize: 11, barGap: 6 };
|
|
96
|
+
/**
|
|
97
|
+
* A volta bracket as in the reference: a line whose slanted ends come down towards the bar lines
|
|
98
|
+
* it spans (over their outer edges, stopping `barGap` short of them), and the ending's number as a
|
|
99
|
+
* Roman numeral in a circle at its middle. A bracket that runs on into the next system has no
|
|
100
|
+
* closing end.
|
|
101
|
+
*/
|
|
102
|
+
function renderVolta(v, y, endY) {
|
|
103
|
+
const { radius: r, slant } = VOLTA;
|
|
104
|
+
const left = v.x1 + (v.startBar ? barlineEdges(v.startBar).right : 0);
|
|
105
|
+
const right = v.x2 + barlineEdges(v.endBar).left;
|
|
106
|
+
const cx = (left + right) / 2;
|
|
107
|
+
const closing = v.openEnd ? "" : ` L ${right} ${endY}`;
|
|
108
|
+
const line = (d) => ({ kind: "path", role: "volta", d, width: 0.9, tone: "ink" });
|
|
109
|
+
return [
|
|
110
|
+
line(`M ${left} ${endY} L ${left + slant} ${y} L ${cx - r} ${y}`),
|
|
111
|
+
line(`M ${cx + r} ${y} L ${v.openEnd ? right : right - slant} ${y}${closing}`),
|
|
112
|
+
line(`M ${cx - r} ${y} A ${r} ${r} 0 1 0 ${cx + r} ${y} A ${r} ${r} 0 1 0 ${cx - r} ${y}`),
|
|
113
|
+
{
|
|
114
|
+
kind: "text",
|
|
115
|
+
role: "volta-number",
|
|
116
|
+
x: cx,
|
|
117
|
+
y,
|
|
118
|
+
text: toRoman(v.number),
|
|
119
|
+
size: VOLTA.numberSize,
|
|
120
|
+
anchor: "middle",
|
|
121
|
+
font: "volta",
|
|
122
|
+
bold: true,
|
|
123
|
+
tone: "ink",
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
/** Chord symbols above the first row, centred on their columns. */
|
|
128
|
+
function renderChords(markings, headroom) {
|
|
129
|
+
return markings.chords.map((chord) => ({
|
|
130
|
+
kind: "text",
|
|
131
|
+
role: "chord",
|
|
132
|
+
owner: chord.key,
|
|
133
|
+
x: chord.x,
|
|
134
|
+
y: chordCenter(headroom),
|
|
135
|
+
text: chord.text,
|
|
136
|
+
size: NOTATION.chordSize,
|
|
137
|
+
anchor: "middle",
|
|
138
|
+
font: "text",
|
|
139
|
+
tone: "ink",
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Chord symbols, volta brackets with their numbers, section labels and the first measure's
|
|
144
|
+
* number. Brackets and labels sit above the chord band.
|
|
145
|
+
*/
|
|
146
|
+
export function renderMarkings(markings, headroom) {
|
|
147
|
+
// The bands sit on the first row (chords and directions float and take no room): a bracket's
|
|
148
|
+
// line `voltaRise` above it, risen over what is under it; labels above the brackets.
|
|
149
|
+
const y = Math.max(4, headroom - NOTATION.voltaRise - markings.bandLift);
|
|
150
|
+
const voltaY = Math.max(VOLTA.radius + 1.5, headroom - NOTATION.voltaRise);
|
|
151
|
+
// The first row starts at `headroom`; its bar lines start `barHalfHeight` above its digits.
|
|
152
|
+
const barTop = headroom + NOTATION.digitY - NOTATION.barHalfHeight;
|
|
153
|
+
const voltas = markings.voltas.flatMap((v) => renderVolta(v, voltaY - v.lift, barTop - VOLTA.barGap));
|
|
154
|
+
// Labels and key changes sit above the volta band when the system has one.
|
|
155
|
+
const labelY = y + 2 - (markings.voltas.length ? NOTATION.headroom : 0);
|
|
156
|
+
const labels = markings.labels.flatMap((l) => [
|
|
157
|
+
{
|
|
158
|
+
kind: "text",
|
|
159
|
+
role: "section-label",
|
|
160
|
+
x: l.x + 2,
|
|
161
|
+
y: labelY,
|
|
162
|
+
text: `${l.text} :`,
|
|
163
|
+
size: LABEL_SIZE,
|
|
164
|
+
anchor: "start",
|
|
165
|
+
font: "text",
|
|
166
|
+
bold: true,
|
|
167
|
+
italic: true,
|
|
168
|
+
tone: "ink",
|
|
169
|
+
},
|
|
170
|
+
...(l.ruleTo === null ? [] : [sectionRule(l, labelY)]),
|
|
171
|
+
]);
|
|
172
|
+
const navigation = markings.navigation.map((n) => ({
|
|
173
|
+
kind: "text",
|
|
174
|
+
role: "navigation",
|
|
175
|
+
x: n.x,
|
|
176
|
+
y: labelY,
|
|
177
|
+
text: n.text,
|
|
178
|
+
size: LABEL_SIZE,
|
|
179
|
+
anchor: "end",
|
|
180
|
+
font: "text",
|
|
181
|
+
bold: true,
|
|
182
|
+
italic: true,
|
|
183
|
+
tone: "ink",
|
|
184
|
+
}));
|
|
185
|
+
const tempos = markings.tempos.map((t) => ({
|
|
186
|
+
kind: "text",
|
|
187
|
+
role: "tempo-mark",
|
|
188
|
+
x: t.x,
|
|
189
|
+
y: labelY,
|
|
190
|
+
text: t.text,
|
|
191
|
+
size: TEMPO_MARK_SIZE,
|
|
192
|
+
anchor: "start",
|
|
193
|
+
font: "text",
|
|
194
|
+
bold: true,
|
|
195
|
+
tone: "ink",
|
|
196
|
+
}));
|
|
197
|
+
const keyY = (k) => (k.atBracket ? overBracketY(headroom) : labelY);
|
|
198
|
+
const keys = markings.keys.flatMap((k) => [
|
|
199
|
+
{
|
|
200
|
+
kind: "text",
|
|
201
|
+
role: "key-change",
|
|
202
|
+
x: k.x,
|
|
203
|
+
y: keyY(k),
|
|
204
|
+
text: k.text,
|
|
205
|
+
size: KEY_CHANGE_SIZE,
|
|
206
|
+
anchor: "start",
|
|
207
|
+
font: "text",
|
|
208
|
+
bold: true,
|
|
209
|
+
tone: "ink",
|
|
210
|
+
},
|
|
211
|
+
keyChangeFrame(k, keyY(k)),
|
|
212
|
+
]);
|
|
213
|
+
const number = markings.measureNumber
|
|
214
|
+
? [
|
|
215
|
+
{
|
|
216
|
+
kind: "text",
|
|
217
|
+
role: "measure-number",
|
|
218
|
+
x: markings.measureNumber.x,
|
|
219
|
+
y: headroom + 2,
|
|
220
|
+
text: markings.measureNumber.text,
|
|
221
|
+
size: 8,
|
|
222
|
+
anchor: "end",
|
|
223
|
+
font: "text",
|
|
224
|
+
italic: true,
|
|
225
|
+
tone: "rule",
|
|
226
|
+
},
|
|
227
|
+
]
|
|
228
|
+
: [];
|
|
229
|
+
return [...renderChords(markings, headroom), ...voltas, ...labels, ...navigation, ...tempos, ...keys, ...number];
|
|
230
|
+
}
|
|
231
|
+
/** The thin line from the end of a section label to the end of its system. */
|
|
232
|
+
function sectionRule(label, y) {
|
|
233
|
+
const start = label.x + 2 + textWidth(`${label.text} :`, LABEL_SIZE) * 1.1 + SECTION_RULE_GAP;
|
|
234
|
+
return {
|
|
235
|
+
kind: "line",
|
|
236
|
+
role: "section-rule",
|
|
237
|
+
x1: start,
|
|
238
|
+
y1: y,
|
|
239
|
+
x2: Math.max(start, label.ruleTo ?? start),
|
|
240
|
+
y2: y,
|
|
241
|
+
width: 0.6,
|
|
242
|
+
tone: "rule",
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/** The frame around "1 = F" (the text is set on its centre line, `y`). */
|
|
246
|
+
function keyChangeFrame(k, y) {
|
|
247
|
+
const left = k.x - KEY_FRAME_PAD.x;
|
|
248
|
+
const right = k.x + k.width + KEY_FRAME_PAD.x;
|
|
249
|
+
const top = y - KEY_CHANGE_SIZE / 2 - KEY_FRAME_PAD.y;
|
|
250
|
+
const bottom = y + KEY_CHANGE_SIZE / 2 + KEY_FRAME_PAD.y;
|
|
251
|
+
return { kind: "path", role: "key-change-frame", d: `M ${left} ${top} H ${right} V ${bottom} H ${left} Z`, width: 1, tone: "ink" };
|
|
252
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MeasureBounds, Row } from "../layout/systemLayout.js";
|
|
2
|
+
import type { NotationProfile } from "../notation/profile.js";
|
|
3
|
+
import type { Primitive } from "./primitives.js";
|
|
4
|
+
/**
|
|
5
|
+
* A key change's box (ADR 0010): a frame over the rows with a pivot, and in each the part's last note in
|
|
6
|
+
* the old key, an arrow, and the same pitch in the new key ("5 → 3"). Drawn only where shown.
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderKeyBox(rows: readonly Row[], bounds: MeasureBounds, profile: NotationProfile): Primitive[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { NOTATION } from "../layout/notationMetrics.js";
|
|
2
|
+
import { renderSpelling } from "./sliceRenderer.js";
|
|
3
|
+
/** Air between the box's border and the rows' bar line ends. */
|
|
4
|
+
const BOX_PAD = 2;
|
|
5
|
+
/**
|
|
6
|
+
* A key change's box (ADR 0010): a frame over the rows with a pivot, and in each the part's last note in
|
|
7
|
+
* the old key, an arrow, and the same pitch in the new key ("5 → 3"). Drawn only where shown.
|
|
8
|
+
*/
|
|
9
|
+
export function renderKeyBox(rows, bounds, profile) {
|
|
10
|
+
return [bounds.keyMark?.box, bounds.closingKeyBox].flatMap((box) => (box ? renderBox(rows, box, bounds.measureId, profile) : []));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One box, floating around the rows that have a pivot (from the first such row to the last), so
|
|
14
|
+
* it never covers a part with no note before the change. A box none of whose rows has a pivot
|
|
15
|
+
* (those parts are not on this line) is left out: it would be an empty frame.
|
|
16
|
+
*/
|
|
17
|
+
function renderBox(rows, box, measureId, profile) {
|
|
18
|
+
const pivotRows = rows.filter((row) => box.pivots[row.partIndex]);
|
|
19
|
+
if (pivotRows.length === 0)
|
|
20
|
+
return [];
|
|
21
|
+
const top = pivotRows[0].noteY - NOTATION.barHalfHeight - BOX_PAD;
|
|
22
|
+
const bottom = pivotRows[pivotRows.length - 1].noteY + NOTATION.barHalfHeight + BOX_PAD;
|
|
23
|
+
const right = box.x + box.width;
|
|
24
|
+
const frame = {
|
|
25
|
+
kind: "path",
|
|
26
|
+
role: "key-box",
|
|
27
|
+
owner: measureId,
|
|
28
|
+
d: `M ${box.x} ${top} H ${right} V ${bottom} H ${box.x} Z`,
|
|
29
|
+
width: 1,
|
|
30
|
+
tone: "ink",
|
|
31
|
+
};
|
|
32
|
+
const quarter = box.width / 4;
|
|
33
|
+
const pivots = rows.flatMap((row) => {
|
|
34
|
+
const pivot = box.pivots[row.partIndex];
|
|
35
|
+
if (!pivot)
|
|
36
|
+
return [];
|
|
37
|
+
const owner = measureId;
|
|
38
|
+
const arrow = {
|
|
39
|
+
kind: "text",
|
|
40
|
+
role: "key-arrow",
|
|
41
|
+
owner,
|
|
42
|
+
x: box.x + box.width / 2,
|
|
43
|
+
y: row.noteY,
|
|
44
|
+
text: "→",
|
|
45
|
+
size: NOTATION.pivotArrowSize,
|
|
46
|
+
anchor: "middle",
|
|
47
|
+
font: "text",
|
|
48
|
+
tone: "ink",
|
|
49
|
+
};
|
|
50
|
+
return [
|
|
51
|
+
...renderSpelling(pivot.from, { x: box.x + quarter, noteY: row.noteY, owner }, profile),
|
|
52
|
+
arrow,
|
|
53
|
+
...renderSpelling(pivot.to, { x: right - quarter, noteY: row.noteY, owner }, profile),
|
|
54
|
+
];
|
|
55
|
+
});
|
|
56
|
+
return [frame, ...pivots];
|
|
57
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SystemLyrics } from "../layout/lyricsLayout.js";
|
|
2
|
+
import type { Primitive } from "./primitives.js";
|
|
3
|
+
/** Syllables, hyphens, elision arcs and extender lines of one system (PRD FR-053..FR-056). */
|
|
4
|
+
export declare function renderLyrics(lyrics: SystemLyrics): Primitive[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Syllables, hyphens, elision arcs and extender lines of one system (PRD FR-053..FR-056). */
|
|
2
|
+
export function renderLyrics(lyrics) {
|
|
3
|
+
const text = (role, owner, x, y, value, anchor = "middle") => ({
|
|
4
|
+
kind: "text",
|
|
5
|
+
role,
|
|
6
|
+
owner,
|
|
7
|
+
x,
|
|
8
|
+
y,
|
|
9
|
+
text: value,
|
|
10
|
+
size: lyrics.size,
|
|
11
|
+
anchor,
|
|
12
|
+
font: "lyrics",
|
|
13
|
+
tone: "ink",
|
|
14
|
+
});
|
|
15
|
+
return [
|
|
16
|
+
...lyrics.syllables.map((s) => text("lyric", s.eventId, s.textX, s.y, s.text, s.anchor)),
|
|
17
|
+
...lyrics.hyphens.map((h) => text("hyphen", h.eventId, h.x, h.y, "-")),
|
|
18
|
+
...lyrics.elisions.map((e) => {
|
|
19
|
+
// Just under the letters' foot (text is set on its central baseline), dipping a little.
|
|
20
|
+
const y = e.y + lyrics.size * 0.36;
|
|
21
|
+
const dip = y + lyrics.size * 0.2;
|
|
22
|
+
const pull = (e.x2 - e.x1) / 4;
|
|
23
|
+
return {
|
|
24
|
+
kind: "path",
|
|
25
|
+
role: "elision",
|
|
26
|
+
owner: e.eventId,
|
|
27
|
+
d: `M ${e.x1} ${y} C ${e.x1 + pull} ${dip}, ${e.x2 - pull} ${dip}, ${e.x2} ${y}`,
|
|
28
|
+
width: 0.8,
|
|
29
|
+
tone: "ink",
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
...lyrics.extenders.map((e) => ({
|
|
33
|
+
kind: "line",
|
|
34
|
+
role: "extender",
|
|
35
|
+
owner: e.eventId,
|
|
36
|
+
x1: e.x1,
|
|
37
|
+
y1: e.y,
|
|
38
|
+
x2: e.x2,
|
|
39
|
+
y2: e.y,
|
|
40
|
+
width: 0.8,
|
|
41
|
+
tone: "ink",
|
|
42
|
+
})),
|
|
43
|
+
];
|
|
44
|
+
}
|