Files
hcie-rust-v3.05/.kilo/plans/stroke-tune-all-psds.md
T
2026-07-09 02:59:53 +03:00

3.2 KiB
Executable File

Plan: Stroke Tune — Cover All Individual PSD Files + Fix Stroke Opacity

Problem

  1. Incomplete test coverage: tune_mae_stroke.rs only loads composite PSDs (stroke-inside.psd, stroke-outside.psd). The 9 individual PSD files (Shape 1.psd, Shape 2.psd, etc.) are NOT tested. The reference PNGs were exported from these individual PSDs, so comparing against layers extracted from the composite may be wrong (different canvas size, pixel data).

  2. Stroke opacity still broken: MAE for Shape 2 (stroke_opacity=0.50) is 4.06 — essentially unchanged even with the O(R²) baseline algorithm. The user confirms this is specifically about the stroke effect's own Opacity setting (50% in the Layer Style dialog), not layer/fill opacity.

Files to Change

hcie-io/examples/tune_mae_stroke.rs

A. Load ALL PSD files — both individual and composite:

Current code only loads 2 composite PSDs. Replace with a list of ALL PSD/PNG pairs:

stroke-inside/ directory:

PSD PNG Reference Notes
stroke-inside.psd stroke-inside.png Composite — has layers Shape 1-4
Shape 1.psd Shape 1.png Individual — 1 layer
Shape 2.psd Shape 2.png Individual — 1 layer, 50% stroke opacity
Shape 3.psd Shape 3.png Individual — 1 layer, 50% stroke opacity
Shape 4.psd Shape 4.png Individual — 1 layer

stroke-outside/ directory:

PSD PNG Reference Notes
stroke-outside.psd stroke-outside.png Composite — has layers Shape 1-3, Layer 2
Shape 1.psd Shape 1.png Individual
Shape 2.psd Shape 2.png Individual
Shape 3.psd Shape 3.png Individual
Layer 2.psd Layer 2.png Individual
Layer 1.psd (no PNG) Skip — no reference image

Change the data structure from (composite_psd, png_dir) to a flat list of (psd_path, png_ref_path) tuples. Each entry maps one PSD to one PNG. For composite PSDs, iterate layers and match each layer name to its PNG. For individual PSDs, the PNG stem is the PSD filename.

B. Deduplicate: When both composite and individual PSDs produce the same layer, prefer the individual PSD (it's the one that produced the PNG).

hcie-fx/src/stroke.rs

The opacity is now baked in (line 113: stroke_alpha[i] * opacity). No further changes needed here.

hcie-fx/src/shadow.rs

Opacity is passed as 1.0 to composite_inside_effect for stroke (line 128). No further changes needed.

Execution Order

  1. Rewrite the test-case loading in tune_mae_stroke.rs to enumerate all individual PSDs + composite PSDs
  2. Build and run to see new per-layer MAE values across all files
  3. Analyze which layers still have high MAE and why — the individual PSDs may reveal different canvas sizes, pixel data, or effect parameters that explain the opacity discrepancy
  4. Fix any remaining stroke opacity issues based on the new data

Expected Outcome

  • 13+ test cases covering all PSD files (not just 8 from composites)
  • Individual PSDs tested with their correct reference PNGs → MAE should improve
  • Clear visibility into per-layer accuracy for stroke opacity cases