Palette cycles + gradient modes (wrap/mirror) - #41
Merged
Conversation
Add map_brightness_rgb_cycled / map_brightness_cycled that insert a PaletteCycle remap at pass-order step 5 (between the tone curve and the gradient lookup). The public map_brightness_rgb / map_brightness keep their existing signatures and delegate with PaletteCycle::default() so all ~136 existing callers stay byte-identical. colorize_subpixel gains a trailing cycle: PaletteCycle param and routes the base color through the cored fn. frame_buffer.rs and png.rs updated with PaletteCycle::default() stubs (marked TODO(task4)) to keep the build green.
…faults Adds palette_cycle field to RenderArtDefaults (identity default for all presets), two new CLI flags (--palette-cycles N, --palette-cycle-mode MODE), a palette_cycle_mode_parsed() accessor, and extends to_render_art_defaults to override art.palette_cycle when either flag is explicitly set.
Add `palette_cycle: PaletteCycle` as a trailing param to `from_downsampled`, `from_downsampled_at`, `create_cell`, `render_colored_cell`, `png_pixel_color`, and `save_frame_as_png`. Replace all TODO(task4) stubs with the threaded value. Wire `initial_palette_cycle` from `to_render_art_defaults()` into the renderer via `set_palette_cycle` and into `RuntimeState.palette_cycle` at startup. The 256-color branch now routes through `map_brightness_cycled` for consistency. With the identity cycle (default), output is byte-identical; all 47 golden regression tests pass unchanged.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements palette cycles (lever 6, #33): spatial palette repeat that remaps the gradient index pre-lookup so a palette tiles across the brightness range.
What
--palette-cycles <N>(1 = off, default) and--palette-cycle-mode <wrap|mirror>(mirror default).fract(t·n)(seam unless palette endpoints match)1 − |1 − fract(t·n)·2|(ping-pong, seamless on any palette)serde(default)back-compat) + per-preset render defaults via the existingRenderArtDefaultspayload.Design
map_brightness_rgb/map_brightness. The public functions keep their signatures and delegate with an identity cycle, so the ~136 UI-swatch callers are untouched; only the render chokepoints (colorize_subpixel, the 256 branch, PNG export) consume the cycle.intensity_mapping:RenderArtDefaults→RuntimeState/renderer →from_downsampled*→ colorizer, and through PNG export andsync_renderer_caches(config-load).Mechanism-only ship
Every preset defaults to identity (cycles = 1), so output is byte-identical and the 47 golden tests are unchanged. Tasteful per-preset cycle values are deferred to the showcase-presets issue (#36).
Test plan
cargo clippy --all-targets --all-features -- -D warningsclean; 819 lib + 47 golden + 19 integration pass.--preset coralbyte-identical vs dev;--palette-cycles 4 --palette-cycle-mode mirrorvisibly changes output.Closes #33.