@real-music-packages/web-core 0.24.0 → 0.24.1
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/dist/scene/index.d.ts +3 -0
- package/dist/scene/index.js +6 -2
- package/dist/scene/index.js.map +1 -1
- package/package.json +1 -1
package/dist/scene/index.d.ts
CHANGED
|
@@ -1840,6 +1840,9 @@ interface ScaleHighlightProps {
|
|
|
1840
1840
|
label?: boolean;
|
|
1841
1841
|
/** Override the label text. Default `${root} ${PrettyScale}`. */
|
|
1842
1842
|
labelText?: string;
|
|
1843
|
+
/** Label vertical position as a fraction of H. Default near the safe-box top.
|
|
1844
|
+
* Set this when the host already draws a top title so the name doesn't collide. */
|
|
1845
|
+
labelCenterFrac?: number;
|
|
1843
1846
|
}
|
|
1844
1847
|
declare const scaleHighlightFactory: LayerFactory<ScaleHighlightProps>;
|
|
1845
1848
|
|
package/dist/scene/index.js
CHANGED
|
@@ -4005,6 +4005,7 @@ function scaleHighlightLayer() {
|
|
|
4005
4005
|
let alpha = 0.55;
|
|
4006
4006
|
let label = true;
|
|
4007
4007
|
let labelTextProp;
|
|
4008
|
+
let labelCenterFrac;
|
|
4008
4009
|
return {
|
|
4009
4010
|
key: "scale-highlight",
|
|
4010
4011
|
init(_ctx, props) {
|
|
@@ -4015,6 +4016,7 @@ function scaleHighlightLayer() {
|
|
|
4015
4016
|
alpha = props.alpha ?? 0.55;
|
|
4016
4017
|
label = props.label ?? true;
|
|
4017
4018
|
labelTextProp = props.labelText;
|
|
4019
|
+
labelCenterFrac = props.labelCenterFrac;
|
|
4018
4020
|
},
|
|
4019
4021
|
draw(ctx, _tMs) {
|
|
4020
4022
|
const c = ctx.ctx2d;
|
|
@@ -4045,8 +4047,9 @@ function scaleHighlightLayer() {
|
|
|
4045
4047
|
c.fillStyle = ctx.theme.ink;
|
|
4046
4048
|
c.font = `700 ${Math.round(ctx.H * 0.03)}px ${ctx.theme.fontDisplay}`;
|
|
4047
4049
|
c.textAlign = "center";
|
|
4048
|
-
c.textBaseline = "top";
|
|
4049
|
-
|
|
4050
|
+
c.textBaseline = labelCenterFrac != null ? "middle" : "top";
|
|
4051
|
+
const ly = labelCenterFrac != null ? ctx.H * labelCenterFrac : sb.top + sb.h * 0.04;
|
|
4052
|
+
c.fillText(text, ctx.W / 2, ly);
|
|
4050
4053
|
c.restore();
|
|
4051
4054
|
}
|
|
4052
4055
|
}
|
|
@@ -4066,6 +4069,7 @@ var scaleHighlightFactory = {
|
|
|
4066
4069
|
if (p.alpha != null && (typeof p.alpha !== "number" || p.alpha < 0 || p.alpha > 1)) errs.push("scale-highlight.alpha must be in [0,1]");
|
|
4067
4070
|
if (p.label != null && typeof p.label !== "boolean") errs.push("scale-highlight.label must be a boolean");
|
|
4068
4071
|
if (p.labelText != null && typeof p.labelText !== "string") errs.push("scale-highlight.labelText must be a string");
|
|
4072
|
+
if (p.labelCenterFrac != null && (typeof p.labelCenterFrac !== "number" || p.labelCenterFrac < 0 || p.labelCenterFrac > 1)) errs.push("scale-highlight.labelCenterFrac must be in [0,1]");
|
|
4069
4073
|
return errs;
|
|
4070
4074
|
}
|
|
4071
4075
|
};
|