fix: close five Θ-W6-T1 review minors — headroom figure, knob-face radius, degenerate band clamp

Aligns inKnobFace's hit radius with computeKnob's draw-side min(w,h) rule and adds a non-square-rect test; clamps halfSpan for degenerate waveform bands with a test; fixes stale docs/comments and annotates an uncommitted perf measurement.
This commit is contained in:
2026-08-01 10:01:40 -04:00
parent ca464397b2
commit 47f2a063e7
8 changed files with 57 additions and 10 deletions
+16 -1
View File
@@ -197,7 +197,9 @@ static void testWaveformColumnCount() {
// The regression this exists to catch: rounding applied to the resulting y instead of to the
// scaled amplitude draws a symmetric column one pixel taller above the zero line than below.
static void testSymmetricColumnDrawsEqualHeightAboveAndBelowTheZeroLine() {
const WaveformBand band = waveformBand(0, 41); // odd height -> fractional half-span
// Odd height so midY sits equidistant from lo/hi — the fractional half-span below comes
// from the amplitude product, not the height's parity.
const WaveformBand band = waveformBand(0, 41);
// Sweep amplitudes whose scaled value is fractional, which is where the two edges can
// round in opposite directions.
for (int i = 1; i <= 20; ++i) {
@@ -256,6 +258,18 @@ static void testBandMetricsMirrorTheDrawnInset() {
CHECK(b.halfSpan == 18.0); // half the band, less the 2px breathing room
}
// A band too short for the 2px breathing room (height <= 4, so height/2 - 2 <= 0) must clamp
// halfSpan to 0 rather than go negative and mirror every positive column below the zero line.
static void testDegenerateBandClampsHalfSpanToZero() {
CHECK(waveformBand(0, 4).halfSpan == 0.0);
CHECK(waveformBand(0, 3).halfSpan == 0.0);
CHECK(waveformBand(0, 0).halfSpan == 0.0);
// A zero half-span collapses every column onto the zero line regardless of amplitude sign.
const WaveformBand b = waveformBand(10, 4);
const WaveformColumnSpan s = waveformColumnSpan(b, 1.0, -1.0);
CHECK(s.top == b.midY && s.bottom == b.midY);
}
int main() {
testHitTestBoxHalfOpen();
testButtonBoxInset();
@@ -279,6 +293,7 @@ int main() {
testTallerAmplitudeNeverDrawsAShorterColumn();
testBothEdgesAndTheStrokeClampToTheBand();
testBandMetricsMirrorTheDrawnInset();
testDegenerateBandClampsHalfSpanToZero();
if (g_fail == 0) std::printf("component_geometry: all tests passed\n");
else std::printf("component_geometry: %d CHECK(s) FAILED\n", g_fail);