Math: tileable noise, display gamma and explicit channel springs #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Math"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Base:
master@ab5e4bc. Two commits, 6 files, +282/−106, all authored byagent.Tileable noise
Why: brushes need repeatable paper-grain and deckle textures without visible seams.
How:
TileableNoisebuilds a seeded 256-entry permutation table (duplicated to 512) and evaluates 2D gradient noise. Cell coordinates wrap at the requested period, corner gradients are interpolated with a quintic fade, and the result is scaled into approximately[-1, 1].fractal()sums weighted octaves, multiplying both sample frequency and period by two at each step, then normalizes by total weight so every octave remains tileable.Tests cover periodicity, lattice zeros, bounds, seed variation, octave tiling and deterministic patterns.
Display gamma
Why: linear-light paint blending needs a small, shared conversion rather than duplicating gamma tables in brush code.
How:
gammaToLinear()appliespow(encoded, 2.2)andlinearToGamma()applies the inverse, both clamped to[0, 1]. Tests check reference values, round trips and clamping.Springs
Why: animation must be driven by the caller's actual frame delta rather than a global clock, and the same spring implementation should work for scalar and compound values without duplicated logic.
How:
SpringValue::step(deltaMs)integrates in substeps of at most 1 ms using stiffness and damping. Callers can set targets, snap, launch with initial velocity, choose parameters (including a critically damped response preset), and query settling using both position tolerance and a 16 ms velocity horizon.SpringChannels<N>applies the same stepping toSpringVec2,SpringRectandSpringColor.Verification
A separate smoke program exercised scalar/vector/rect/colour springs, initial launch, substepping and settling.
CMakeLists.txtis unchanged: the port'sMODULES_BUILD_TESTSgate does not exist on master.