6.0 KiB
Executable File
6.0 KiB
Executable File
Refactor: Split hcie-fx/src/shadow.rs into Domain Modules
Goal
Split the monolithic shadow.rs (1482 lines containing 10+ effect generators + helpers) into focused modules: emboss.rs, outer_glow.rs, etc. Keep shadow.rs containing only apply_layer_effects, generate_shadow, generate_inner_shadow, and shared helpers (box_blur, box_blur_f32, smoothstep, composites).
Handover from Planning Session
Discoveries
generate_bevel_embossis called directly (not via a re-export) fromapply_layer_effectsat line 58 ofshadow.rs— it's a plain function callgenerate_bevel_emboss(...), notself::generate_bevel_emboss(...). After moving it toemboss.rs, need to adduse crate::emboss::generate_bevel_emboss;at top ofshadow.rs.- No other crate or file calls individual effect generators directly — only
tune_mae_emboss.rsandtune_mae_outer_glow.rscallgenerate_bevel_tuned/generate_glow_tunedviahcie_fx::shadow::.... All other consumers (test_psd_composite.rs, debug_glow.rs, gui.rs, etc.) only callapply_layer_effects(the top-level pub function). generate_bevel_embosshas a duplicategenerate_bevel_tunedalready in shadow.rs (lines 883-1076) with identical math but extra param args. Both must move toemboss.rs.generate_glow_tuneddoes NOT exist in shadow.rs yet — the tune file references it but it was removed during the backup restore. Need to ADD it toouter_glow.rsas part of Phase 2.edt_*functions are private and called only fromgenerate_bevel_emboss/generate_bevel_tuned— safe to move entirely intoemboss.rs.smoothstepis defined but never used in shadow.rs (only referenced in comment). Keep it in shadow.rs for now.box_blur(u8 version) is defined but only shadow.rs internal functions call it — all effect generators usebox_blur_f32(f32 version).box_blurcan stay in shadow.rs aspub(crate).sample_gradientis a private helper only used bygenerate_gradient_overlay— will move with overlays in Phase 3.
Relevant Files
/mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-fx/src/shadow.rs— 1482 lines, the monolithic source to split.apply_layer_effects(pub), 10 effect generators (fn), plus EDT, blur, composite helpers./mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-fx/src/lib.rs— declarespub mod shadow;. Needspub mod emboss;,pub mod outer_glow;etc./mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-io/examples/tune_mae_emboss.rs— callshcie_fx::shadow::generate_bevel_tunedat line 202. Needs update tohcie_fx::emboss::generate_bevel_tuned./mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-io/examples/tune_mae_outer_glow.rs— callshcie_fx::shadow::generate_glow_tunedat line 81. Needs update tohcie_fx::outer_glow::generate_glow_tuned./mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-io/examples/test_sultan.rs— useshcie_fx::shadow::apply_layer_effectsindirectly via hcie_composite. No change needed./mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-io/src/test_psd_composite.rs— useshcie_fx::apply_layer_effects(re-exported from lib.rs). No change needed./mnt/extra/00_PROJECTS/hcie-rust-v4/hcie-io/examples/gui.rs— useshcie_fx::protocol_to_hcie_fx_effect,hcie_fx::LayerEffectenum, etc. No change needed as long as lib.rs re-exports are intact.
Implementation Notes
- Do Phase 1 first (emboss.rs), then verify cargo check passes, then tune. After Phase 1, the
tune_mae_embossexample uses the new module path, buttune_mae_outer_glowwill still referencehcie_fx::shadow::generate_glow_tunedwhich won't exist yet — that's fine, only build the specific example. - Use
cargo check --package hcie-fxfirst to verify the library compiles, thencargo check --example tune_mae_emboss --releasefor the example. generate_bevel_tunedis labeledpubin shadow.rs — it needs to stay pub in emboss.rs for the tune example to call it.- The BEGIN_TUNING_ZONE/END_TUNING_ZONE comments in shadow.rs (lines 828 and 878) should move WITH
generate_bevel_embossinto emboss.rs so the tune script can still find them by string matching. Same for BEGIN_GLOW_TUNING_ZONE/END_GLOW_TUNING_ZONE ingenerate_glow. - After Phase 2, the backup
shadow.rs.bakshould be updated (or deleted) since it no longer matches the refactored structure. - Running
test_sultanafter all phases requires all crate examples to compile — don't leave broken references in example files. Either fix both tune examples after each phase, or only run the specific working example.
Todo List
- [~] Fix tune_eval vs production mismatch — the tune scripts (
tune_mae_emboss,tune_mae_outer_glow) and the production functions (generate_bevel_emboss,generate_glow) have diverged. The tune versions have additional parameters and different tuning zone structures. Need to reconcile: either fold tune params into production, or make production call the tuned version with default params. - Phase 1: Extract emboss.rs from shadow.rs
- Copy
generate_bevel_emboss(lines ~796-882),generate_bevel_tuned(lines 883-1076), andedt_*helpers to newemboss.rs - Add
pub mod emboss;tolib.rs - Add
use crate::emboss::generate_bevel_emboss;toshadow.rs - Remove the moved functions from
shadow.rs - Update
tune_mae_emboss.rsto usehcie_fx::emboss::generate_bevel_tuned - Verify with
cargo check --package hcie-fxandcargo check --example tune_mae_emboss --release
- Copy
- Phase 2: Extract outer_glow.rs from shadow.rs
- Add
generate_glow_tuned(production version + tuned version) toouter_glow.rs - Add
pub mod outer_glow;tolib.rs - Add
use crate::outer_glow::*;toshadow.rs - Remove
generate_glowfromshadow.rs - Update
tune_mae_outer_glow.rsto usehcie_fx::outer_glow::generate_glow_tuned - Verify with
cargo check
- Add
- Phase 3: Extract overlay modules (gradient_overlay, pattern_overlay, stroke, color_overlay)
- Final: Clean up, delete
shadow.rs.bak, runtest_sultan