Region fade between rebuilds + compute off switch
The region bitmap rebuilds only every REGION_EVERY-th frame while the
live sim runs, so during drags the tints stepped at 1/3 the frame
rate. Between rebuilds draw() now linearly blends the previous final
bitmap into the current one ('lighter' + globalAlpha weights = a true
lerp of the premultiplied pixels — no source-over alpha stacking).
Because box blur and the end-alpha scale are linear operators, lerping
the finished bitmaps is equivalent to fading coverage before the blur,
the mathematically exact form of the user's preferred pipeline. Two
tiny GPU blits per frame; splat/blur/readback still only on rebuilds.
New RegionTuning.enabled is a compute switch (not a paint toggle):
off skips the entire build (splat, blur, readback, blit) — the settings
panel exposes it as "Background colors". Cluster labels stay decoupled
and follow clusterLabels. Old persisted files predate the field and
sanitize to enabled: true.
This commit is contained in:
@@ -214,4 +214,16 @@ describe("slider mapping (log scale, default-centered)", () => {
|
||||
// Stored blur 0 (the old off zone) snaps back into the set.
|
||||
assert.equal(sanitizeRegionTuning({ blur: 0 }).blur, 2);
|
||||
});
|
||||
|
||||
test("enabled is the compute off switch: only an explicit false turns it off", () => {
|
||||
// Default on; old persisted files predate the field (missing → on);
|
||||
// garbage falls back to on (fail toward the tuned look).
|
||||
assert.equal(DEFAULT_REGION_TUNING.enabled, true);
|
||||
assert.equal(sanitizeRegionTuning({}).enabled, true);
|
||||
assert.equal(sanitizeRegionTuning({ enabled: false }).enabled, false);
|
||||
assert.equal(sanitizeRegionTuning({ enabled: true }).enabled, true);
|
||||
assert.equal(sanitizeRegionTuning({ enabled: "no" as unknown as boolean }).enabled, true);
|
||||
// An explicit false survives even alongside garbage in other fields.
|
||||
assert.equal(sanitizeRegionTuning({ enabled: false, blur: 99, bitmap: 99999 }).enabled, false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user