web-music-score 6.0.0-pre.3 → 6.0.0-pre.4

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.
@@ -1251,6 +1251,7 @@ declare class RenderContext {
1251
1251
  private canvas?;
1252
1252
  private ctx?;
1253
1253
  private mdoc?;
1254
+ private paint;
1254
1255
  private cursorRect?;
1255
1256
  private mousePos?;
1256
1257
  private curStaffPos?;
@@ -1269,6 +1270,8 @@ declare class RenderContext {
1269
1270
  private forceDraw;
1270
1271
  private onImageLoaded;
1271
1272
  setDocument(mdoc?: MDocument): void;
1273
+ setPaint(paint?: Paint): void;
1274
+ getPaint(): Paint;
1272
1275
  setCanvas(canvas: HTMLCanvasElement): void;
1273
1276
  setScoreEventListener(fn: ScoreEventListener): void;
1274
1277
  needMouseInput(): boolean;
@@ -1298,7 +1301,7 @@ declare class RenderContext {
1298
1301
  getRestRect(restSize: number): AnchoredRect;
1299
1302
  drawRest(restSize: number, x: number, y: number): void;
1300
1303
  drawFlag(rect: Rect | AnchoredRect, dir: "up" | "down"): void;
1301
- color(color: string): RenderContext;
1304
+ color(color: string | ColorKey): RenderContext;
1302
1305
  lineColor(color: string): RenderContext;
1303
1306
  fillColor(color: string): RenderContext;
1304
1307
  lineWidth(lineWidth?: number): RenderContext;
@@ -1639,6 +1642,67 @@ declare class ScoreObjectEvent extends ScoreEvent {
1639
1642
  /** Score event listener type. */
1640
1643
  type ScoreEventListener = (event: ScoreEvent) => void;
1641
1644
 
1645
+ /** Color keys. */
1646
+ type ColorKey = "hilight.staffpos" | "hilight.object" | "play.cursor" | "background" | "header.title" | "header.composer" | "header.arranger" | "rowgroup.instrument" | "rowgroup.frame" | "staff.frame" | "staff.note" | "staff.rest" | "staff.lyrics" | "staff.connective" | "staff.signature.clef" | "staff.signature.key" | "staff.signature.time" | "staff.signature.tempo" | "staff.signature.measurenum" | "staff.element.fermata" | "staff.element.annotation" | "staff.element.navigation" | "staff.element.label" | "tab.frame" | "tab.note" | "tab.rest" | "tab.lyrics" | "tab.connective" | "tab.tuning" | "tab.signature.clef" | "tab.signature.key" | "tab.signature.time" | "tab.signature.tempo" | "tab.signature.measurenum" | "tab.element.fermata" | "tab.element.annotation" | "tab.element.navigation" | "tab.element.label";
1647
+ /** Function to typecheck a valid ColorKey variable. */
1648
+ declare function colorKey(colorKey: ColorKey): ColorKey;
1649
+ /** Color key parts. */
1650
+ type ColorKeyPart = "background" | "header" | "title" | "composer" | "arranger" | "rowgroup" | "instrument" | "frame" | "staff" | "tab" | "note" | "rest" | "lyrics" | "connective" | "signature" | "clef" | "key" | "time" | "tempo" | "measurenum" | "tuning" | "element" | "fermata" | "annotation" | "navigation" | "label";
1651
+ /**
1652
+ * Paint class for coloring music scores.
1653
+ */
1654
+ declare class Paint {
1655
+ static readonly default: Paint;
1656
+ colors: Record<ColorKey, string>;
1657
+ /**
1658
+ * Set color of any score document element. Use combination of color key parts to set color of specific elements.
1659
+ * ```ts
1660
+ * setColor("all", "red"); // Set color of everything except background.
1661
+ * setColor("staff", "red"); // Set color of all staff elements.
1662
+ * setColor(["staff", "signature"], "red"); // Set color of all staff signature elements.
1663
+ * setColor(["staff", "signature", "key"], "red"); // Set color of staff key signature.
1664
+ * setColor(["staff", "signature", "time"], "red"); // Set color of staff time signature.
1665
+ * setColor("staff.signature.time", "red"); // Set color of staff time signature.
1666
+ * // etc.
1667
+ * ```
1668
+ *
1669
+ * @param colorKeyOrParts - Color key parts to set color for.
1670
+ * @param color - Color (HTML color code e.g. "green", "#AA6644", etc.)
1671
+ */
1672
+ setColor(colorKeyOrParts: ColorKey | ColorKeyPart | ColorKeyPart[] | "all", color: string): void;
1673
+ /**
1674
+ * Get color.
1675
+ * @param colorKeyOrColor - ColorKey or color.
1676
+ * @returns - Color value (e.g. "white" or "#FFFFFF").
1677
+ */
1678
+ getColor(colorKeyOrColor: ColorKey | string): string;
1679
+ /**
1680
+ * Get color code.
1681
+ * @param colorKeyOrColor - ColorKey or color.
1682
+ * @returns - Color code (e.g. "#FFFFFF").
1683
+ */
1684
+ getColorCode(colorKeyOrColor: ColorKey | string): string;
1685
+ /**
1686
+ * Get color RGBA.
1687
+ * @param colorKeyOrColor - ColorKey or color.
1688
+ * @returns - Color RGBA (e.g. [1, 1, 1, 1]).
1689
+ */
1690
+ getColorRGBA(colorKeyOrColor: ColorKey | string): [number, number, number, number];
1691
+ /**
1692
+ * Convert color name to color code.
1693
+ * @param colorName - Color name (e.g. "white").
1694
+ * @returns - Color code (e.g. "#FFFFFF")
1695
+ */
1696
+ static colorNameToCode(colorName: string): string;
1697
+ /**
1698
+ * Convert color name ro RGBA.
1699
+ * @param colorName - Color name (e.g. "white").
1700
+ * @param alpha - Alpha value 0..1 (default is 1).
1701
+ * @returns - RGBA (e.g. [1, 1, 1, 1]).
1702
+ */
1703
+ static colorNameToRGBA(colorName: string, alpha?: number): [number, number, number, number];
1704
+ }
1705
+
1642
1706
  /** Music player class. */
1643
1707
  declare class MPlayer {
1644
1708
  private static currentlyPlaying;
@@ -1676,6 +1740,12 @@ declare class MRenderContext {
1676
1740
  * Create new render context instance.
1677
1741
  */
1678
1742
  constructor();
1743
+ /**
1744
+ * Set Paint for this render context.
1745
+ * @param paint - Paint.
1746
+ * @returns - This render context instance.
1747
+ */
1748
+ setPaint(paint?: Paint): this;
1679
1749
  /**
1680
1750
  * Attach music document to this render context.
1681
1751
  * @param doc - Music document.
@@ -2395,4 +2465,4 @@ declare class MExtensionLine extends MusicInterface {
2395
2465
  getMusicObject(): ObjExtensionLine;
2396
2466
  }
2397
2467
 
2398
- export { MTabSignature as $, type AnnotationText as A, MHeader as B, Connective as C, MImage as D, MMeasure as E, Fermata as F, MBarLineRight as G, MBarLineLeft as H, MStaffBarLine as I, MNoteGroup as J, MStaffNoteGroup as K, type LyricsOptions as L, MDocument as M, type NoteOptions as N, MTabNoteGroup as O, MRest as P, MStaffRest as Q, type RestOptions as R, StaffPreset as S, type TupletOptions as T, MRhythmColumn as U, type VoiceId as V, MScoreRow as W, MScoreRowGroup as X, MStaff as Y, MTab as Z, MStaffSignature as _, type ScoreConfiguration as a, MTabRhythm as a0, MSpecialText as a1, MText as a2, MLyrics as a3, MExtensionLine as a4, Clef as a5, type BaseConfig as a6, type StaffConfig as a7, type TabConfig as a8, getVoiceIds as a9, isVoiceId as aa, validateVoiceId as ab, type StringNumber as ac, getStringNumbers as ad, isStringNumber as ae, validateStringNumber as af, getVerseNumbers as ag, isVerseNumber as ah, validateVerseNumber as ai, Stem as aj, Arpeggio as ak, type StaffTabOrGroup as al, LyricsAlign as am, LyricsHyphen as an, DynamicsAnnotation as ao, TempoAnnotation as ap, PlayState as aq, type PlayStateChangeListener as ar, type MeasureOptions as b, type VerseNumber as c, type StaffTabOrGroups as d, Navigation as e, Annotation as f, Label as g, TieType as h, NoteAnchor as i, VerticalPosition as j, type ScoreEventType as k, ScoreEvent as l, ScoreStaffPosEvent as m, ScoreObjectEvent as n, type ScoreEventListener as o, MPlayer as p, MRenderContext as q, MPlaybackButtons as r, MusicInterface as s, MAccidental as t, MConnective as u, MArpeggio as v, MBeamGroup as w, MStaffBeamGroup as x, MEnding as y, MFermata as z };
2468
+ export { MTabSignature as $, type AnnotationText as A, MHeader as B, Connective as C, MImage as D, MMeasure as E, Fermata as F, MBarLineRight as G, MBarLineLeft as H, MStaffBarLine as I, MNoteGroup as J, MStaffNoteGroup as K, type LyricsOptions as L, MDocument as M, type NoteOptions as N, MTabNoteGroup as O, MRest as P, MStaffRest as Q, type RestOptions as R, StaffPreset as S, type TupletOptions as T, MRhythmColumn as U, type VoiceId as V, MScoreRow as W, MScoreRowGroup as X, MStaff as Y, MTab as Z, MStaffSignature as _, type ScoreConfiguration as a, MTabRhythm as a0, MSpecialText as a1, MText as a2, MLyrics as a3, MExtensionLine as a4, type ColorKey as a5, colorKey as a6, type ColorKeyPart as a7, Paint as a8, Clef as a9, type BaseConfig as aa, type StaffConfig as ab, type TabConfig as ac, getVoiceIds as ad, isVoiceId as ae, validateVoiceId as af, type StringNumber as ag, getStringNumbers as ah, isStringNumber as ai, validateStringNumber as aj, getVerseNumbers as ak, isVerseNumber as al, validateVerseNumber as am, Stem as an, Arpeggio as ao, type StaffTabOrGroup as ap, LyricsAlign as aq, LyricsHyphen as ar, DynamicsAnnotation as as, TempoAnnotation as at, PlayState as au, type PlayStateChangeListener as av, type MeasureOptions as b, type VerseNumber as c, type StaffTabOrGroups as d, Navigation as e, Annotation as f, Label as g, TieType as h, NoteAnchor as i, VerticalPosition as j, type ScoreEventType as k, ScoreEvent as l, ScoreStaffPosEvent as m, ScoreObjectEvent as n, type ScoreEventListener as o, MPlayer as p, MRenderContext as q, MPlaybackButtons as r, MusicInterface as s, MAccidental as t, MConnective as u, MArpeggio as v, MBeamGroup as w, MStaffBeamGroup as x, MEnding as y, MFermata as z };
@@ -1,4 +1,4 @@
1
- import { M as MDocument } from '../music-objects-DLmp5uL6.js';
1
+ import { M as MDocument } from '../music-objects-ChAdqdR8.js';
2
2
  import '../note-RVXvpfyV.js';
3
3
  import '../tempo-D-JF-8b_.js';
4
4
  import '@tspro/ts-utils-lib';
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v6.0.0-pre.3 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
1
+ /* WebMusicScore v6.0.0-pre.4 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,5 +1,5 @@
1
- /* WebMusicScore v6.0.0-pre.3 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
- import "../chunk-QJ3X3GQ6.mjs";
1
+ /* WebMusicScore v6.0.0-pre.4 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
+ import "../chunk-GNFDJFUO.mjs";
3
3
 
4
4
  // src/pieces/andante-diabelli.ts
5
5
  import { DocumentBuilder } from "web-music-score/score";
@@ -1,12 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import { M as MDocument, o as ScoreEventListener, r as MPlaybackButtons } from '../music-objects-DLmp5uL6.js';
3
+ import { M as MDocument, a8 as Paint, o as ScoreEventListener, r as MPlaybackButtons } from '../music-objects-ChAdqdR8.js';
4
4
  import '../note-RVXvpfyV.js';
5
5
  import '../tempo-D-JF-8b_.js';
6
6
  import '@tspro/ts-utils-lib';
7
7
 
8
8
  interface MusicScoreViewProps {
9
9
  doc: MDocument;
10
+ paint?: Paint;
10
11
  onScoreEvent?: ScoreEventListener;
11
12
  }
12
13
  /**
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v6.0.0-pre.3 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
1
+ /* WebMusicScore v6.0.0-pre.4 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
2
  "use strict";
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -47,6 +47,8 @@ var MusicScoreView = class extends React.Component {
47
47
  super(props);
48
48
  __publicField(this, "ctx");
49
49
  this.ctx = new import_score.MRenderContext();
50
+ if (props.paint)
51
+ this.ctx.setPaint(props.paint);
50
52
  this.ctx.setDocument(props.doc);
51
53
  if (props.onScoreEvent) {
52
54
  this.ctx.setScoreEventListener(props.onScoreEvent);
@@ -1,7 +1,7 @@
1
- /* WebMusicScore v6.0.0-pre.3 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
1
+ /* WebMusicScore v6.0.0-pre.4 | (c) 2023-2025 Stefan Brockmann | MIT License | Includes: Tone.js (MIT License), Color Name to Code (MIT License) */
2
2
  import {
3
3
  __publicField
4
- } from "../chunk-QJ3X3GQ6.mjs";
4
+ } from "../chunk-GNFDJFUO.mjs";
5
5
 
6
6
  // src/react-ui/music-score-view.tsx
7
7
  import * as React from "react";
@@ -12,6 +12,8 @@ var MusicScoreView = class extends React.Component {
12
12
  super(props);
13
13
  __publicField(this, "ctx");
14
14
  this.ctx = new MRenderContext();
15
+ if (props.paint)
16
+ this.ctx.setPaint(props.paint);
15
17
  this.ctx.setDocument(props.doc);
16
18
  if (props.onScoreEvent) {
17
19
  this.ctx.setScoreEventListener(props.onScoreEvent);
@@ -1,58 +1,10 @@
1
- import { N as NoteOptions, R as RestOptions, S as StaffPreset, a as ScoreConfiguration, M as MDocument, b as MeasureOptions, V as VoiceId, T as TupletOptions, c as VerseNumber, L as LyricsOptions, d as StaffTabOrGroups, F as Fermata, e as Navigation, A as AnnotationText, f as Annotation, g as Label, C as Connective, h as TieType, i as NoteAnchor, j as VerticalPosition } from '../music-objects-DLmp5uL6.js';
2
- export { ak as Arpeggio, a6 as BaseConfig, a5 as Clef, ao as DynamicsAnnotation, am as LyricsAlign, an as LyricsHyphen, t as MAccidental, v as MArpeggio, H as MBarLineLeft, G as MBarLineRight, w as MBeamGroup, u as MConnective, y as MEnding, a4 as MExtensionLine, z as MFermata, B as MHeader, D as MImage, a3 as MLyrics, E as MMeasure, J as MNoteGroup, r as MPlaybackButtons, p as MPlayer, q as MRenderContext, P as MRest, U as MRhythmColumn, W as MScoreRow, X as MScoreRowGroup, a1 as MSpecialText, Y as MStaff, I as MStaffBarLine, x as MStaffBeamGroup, K as MStaffNoteGroup, Q as MStaffRest, _ as MStaffSignature, Z as MTab, O as MTabNoteGroup, a0 as MTabRhythm, $ as MTabSignature, a2 as MText, s as MusicInterface, aq as PlayState, ar as PlayStateChangeListener, l as ScoreEvent, o as ScoreEventListener, k as ScoreEventType, n as ScoreObjectEvent, m as ScoreStaffPosEvent, a7 as StaffConfig, al as StaffTabOrGroup, aj as Stem, ac as StringNumber, a8 as TabConfig, ap as TempoAnnotation, ad as getStringNumbers, ag as getVerseNumbers, a9 as getVoiceIds, ae as isStringNumber, ah as isVerseNumber, aa as isVoiceId, af as validateStringNumber, ai as validateVerseNumber, ab as validateVoiceId } from '../music-objects-DLmp5uL6.js';
1
+ import { N as NoteOptions, R as RestOptions, S as StaffPreset, a as ScoreConfiguration, M as MDocument, b as MeasureOptions, V as VoiceId, T as TupletOptions, c as VerseNumber, L as LyricsOptions, d as StaffTabOrGroups, F as Fermata, e as Navigation, A as AnnotationText, f as Annotation, g as Label, C as Connective, h as TieType, i as NoteAnchor, j as VerticalPosition } from '../music-objects-ChAdqdR8.js';
2
+ export { ao as Arpeggio, aa as BaseConfig, a9 as Clef, a5 as ColorKey, a7 as ColorKeyPart, as as DynamicsAnnotation, aq as LyricsAlign, ar as LyricsHyphen, t as MAccidental, v as MArpeggio, H as MBarLineLeft, G as MBarLineRight, w as MBeamGroup, u as MConnective, y as MEnding, a4 as MExtensionLine, z as MFermata, B as MHeader, D as MImage, a3 as MLyrics, E as MMeasure, J as MNoteGroup, r as MPlaybackButtons, p as MPlayer, q as MRenderContext, P as MRest, U as MRhythmColumn, W as MScoreRow, X as MScoreRowGroup, a1 as MSpecialText, Y as MStaff, I as MStaffBarLine, x as MStaffBeamGroup, K as MStaffNoteGroup, Q as MStaffRest, _ as MStaffSignature, Z as MTab, O as MTabNoteGroup, a0 as MTabRhythm, $ as MTabSignature, a2 as MText, s as MusicInterface, a8 as Paint, au as PlayState, av as PlayStateChangeListener, l as ScoreEvent, o as ScoreEventListener, k as ScoreEventType, n as ScoreObjectEvent, m as ScoreStaffPosEvent, ab as StaffConfig, ap as StaffTabOrGroup, an as Stem, ag as StringNumber, ac as TabConfig, at as TempoAnnotation, a6 as colorKey, ah as getStringNumbers, ak as getVerseNumbers, ad as getVoiceIds, ai as isStringNumber, al as isVerseNumber, ae as isVoiceId, aj as validateStringNumber, am as validateVerseNumber, af as validateVoiceId } from '../music-objects-ChAdqdR8.js';
3
3
  import { N as Note } from '../note-RVXvpfyV.js';
4
4
  import { S as ScaleType, c as Scale } from '../scale-B1M10_fu.js';
5
5
  import { N as NoteLength, h as NoteLengthStr, K as KeySignature, a as TimeSignature, T as TimeSignatures, B as BeamGrouping, k as TupletRatio } from '../tempo-D-JF-8b_.js';
6
6
  import '@tspro/ts-utils-lib';
7
7
 
8
- /**
9
- * Color attributes.
10
- * ```
11
- * Attribute hierarchy is:
12
- * + background
13
- * + header
14
- * + title
15
- * + composer
16
- * + arranger
17
- * + rowgroup
18
- * + instrument
19
- * + frame
20
- * + staff|tab
21
- * + frame
22
- * + note
23
- * + rest
24
- * + connective
25
- * + signature
26
- * + clef (staff only)
27
- * + key (staff only)
28
- * + time
29
- * + tempo
30
- * + measurenum
31
- * + tuning (tab only)
32
- * + element
33
- * + fermata
34
- * + annotation
35
- * + navigation
36
- * + label
37
- * ```
38
- */
39
- type ColorAttr = "background" | "header" | "title" | "composer" | "arranger" | "rowgroup" | "instrument" | "frame" | "staff" | "tab" | "frame" | "note" | "rest" | "connective" | "signature" | "clef" | "key" | "time" | "tempo" | "measurenum" | "tuning" | "element" | "fermata" | "annotation" | "navigation" | "label";
40
- /**
41
- * Set color of any score document element. Use combination of color attributes to set color of specific elements.
42
- * ```ts
43
- * setColor("red", "staff"); // Set color of all staff elements to red.
44
- * setColor("red", "staff", "signature"); // Set color of all signature elements of staff to red.
45
- * setColor("red", "staff", "key", "signature"); // Set color of key signature of staff to red.
46
- * setColor("green", "staff", "time", "signature"); // Set color of time signature of staff to green.
47
- * // etc.
48
- * ```
49
- * See {@link ColorAttr} for attribute hierarchy tree.
50
- *
51
- * @param color - Color (HTML color code e.g. "green", "#AA6644", etc.)
52
- * @param colorAttrs - Any number of color attributes.
53
- */
54
- declare function setColor(color: string, ...colorAttrs: ColorAttr[]): void;
55
-
56
8
  /** Tuplet builder type. */
57
9
  type TupletBuilder = {
58
10
  /**
@@ -463,4 +415,4 @@ declare class DocumentBuilder {
463
415
  addScaleArpeggio(scale: Scale, bottomNote: string, numOctaves: number): DocumentBuilder;
464
416
  }
465
417
 
466
- export { Annotation, AnnotationText, type ColorAttr, Connective, DocumentBuilder, type ExtensionBuilder, Fermata, Label, LyricsOptions, MDocument, MeasureOptions, Navigation, NoteAnchor, NoteOptions, RestOptions, ScoreConfiguration, StaffPreset, StaffTabOrGroups, TieType, type TupletBuilder, TupletOptions, VerseNumber, VerticalPosition, VoiceId, setColor };
418
+ export { Annotation, AnnotationText, Connective, DocumentBuilder, type ExtensionBuilder, Fermata, Label, LyricsOptions, MDocument, MeasureOptions, Navigation, NoteAnchor, NoteOptions, RestOptions, ScoreConfiguration, StaffPreset, StaffTabOrGroups, TieType, type TupletBuilder, TupletOptions, VerseNumber, VerticalPosition, VoiceId };