@real-music-packages/web-core 0.25.0 → 0.26.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.
@@ -1793,6 +1793,9 @@ interface CountdownProps {
1793
1793
  centerFrac?: number;
1794
1794
  /** Draw a draining ring around the number. Default true. */
1795
1795
  ring?: boolean;
1796
+ /** Ring radius in px. Default = fontPx*0.62. Set explicitly to align the ring
1797
+ * with another circular element (e.g. whozart's radial ring / portrait). */
1798
+ ringRadius?: number;
1796
1799
  }
1797
1800
  declare const countdownFactory: LayerFactory<CountdownProps>;
1798
1801
 
@@ -3813,6 +3813,7 @@ function countdownLayer() {
3813
3813
  let fontPx = DEFAULTS6.fontPx;
3814
3814
  let centerFrac = DEFAULTS6.centerFrac;
3815
3815
  let ring = DEFAULTS6.ring;
3816
+ let ringRadiusProp;
3816
3817
  return {
3817
3818
  key: "countdown",
3818
3819
  init(_ctx, props) {
@@ -3823,6 +3824,7 @@ function countdownLayer() {
3823
3824
  fontPx = props.fontPx ?? DEFAULTS6.fontPx;
3824
3825
  centerFrac = props.centerFrac ?? DEFAULTS6.centerFrac;
3825
3826
  ring = props.ring ?? DEFAULTS6.ring;
3827
+ ringRadiusProp = props.ringRadius;
3826
3828
  },
3827
3829
  draw(ctx, tMs) {
3828
3830
  const elapsed = tMs - startMs;
@@ -3841,7 +3843,7 @@ function countdownLayer() {
3841
3843
  const fade = 1 - Math.max(0, (tickFrac - 0.7) / 0.3) * 0.85;
3842
3844
  c.save();
3843
3845
  if (ring) {
3844
- const r = fontPx * 0.62;
3846
+ const r = ringRadiusProp ?? fontPx * 0.62;
3845
3847
  c.lineWidth = 10;
3846
3848
  c.lineCap = "round";
3847
3849
  c.strokeStyle = rgba6(col, 0.18 * fade);
@@ -3877,6 +3879,7 @@ var countdownFactory = {
3877
3879
  if (p.fontPx != null && (typeof p.fontPx !== "number" || p.fontPx <= 0)) errs.push("countdown.fontPx must be a positive number");
3878
3880
  if (p.centerFrac != null && (typeof p.centerFrac !== "number" || p.centerFrac < 0 || p.centerFrac > 1)) errs.push("countdown.centerFrac must be in [0,1]");
3879
3881
  if (p.ring != null && typeof p.ring !== "boolean") errs.push("countdown.ring must be a boolean");
3882
+ if (p.ringRadius != null && (typeof p.ringRadius !== "number" || p.ringRadius <= 0)) errs.push("countdown.ringRadius must be a positive number");
3880
3883
  return errs;
3881
3884
  }
3882
3885
  };
@@ -4030,14 +4033,26 @@ function scaleHighlightLayer() {
4030
4033
  const layout = getKeyboardLayout(ctx);
4031
4034
  if (layout) {
4032
4035
  c.save();
4033
- c.globalAlpha = alpha;
4034
4036
  for (let m = layout.lowMidi; m <= layout.highMidi; m++) {
4035
4037
  if (!inRange(layout, m)) continue;
4036
4038
  const pc = pitchClass(m);
4037
4039
  if (!inScale.has(pc)) continue;
4038
4040
  const r = keyRect(layout, m);
4039
- c.fillStyle = pc === root ? tc : sc;
4040
- c.fillRect(r.x, r.y, r.w, r.h);
4041
+ const isTonic = pc === root;
4042
+ const cx = r.x + r.w / 2;
4043
+ const pipR = (r.black ? r.w * 0.5 : r.w * 0.32) * (isTonic ? 1.25 : 1);
4044
+ const cy = r.y + r.h - pipR - (r.black ? 8 : 16);
4045
+ c.globalAlpha = Math.min(1, alpha + 0.4);
4046
+ c.fillStyle = isTonic ? tc : sc;
4047
+ c.beginPath();
4048
+ c.arc(cx, cy, pipR, 0, Math.PI * 2);
4049
+ c.fill();
4050
+ if (isTonic) {
4051
+ c.fillStyle = "#ffffff";
4052
+ c.beginPath();
4053
+ c.arc(cx, cy, pipR * 0.42, 0, Math.PI * 2);
4054
+ c.fill();
4055
+ }
4041
4056
  }
4042
4057
  c.restore();
4043
4058
  }