Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

fix(breathe): a bake handed part of the four range keys reads the rest as 0, as the sidecar and the curator mirror do

Soohong Kimdbe8363b230b
diff --git a/sprite_gen/effects/breathe.py b/sprite_gen/effects/breathe.py
index 9534331..bdbc1e2 100644
--- a/sprite_gen/effects/breathe.py
+++ b/sprite_gen/effects/breathe.py
@@ -89,7 +89,7 @@ from PIL import Image
from sprite_gen._deps import np
from sprite_gen.effects.anatomy import Anatomy, analyze
-from sprite_gen.curate.curation import (BREATHE_MODES, BREATHE_SMOOTH_DEPTH, BREATHE_SMOOTH_DEPTH_X,
+from sprite_gen.curate.curation import (BREATHE_MODES, BREATHE_RANGE_KEYS, BREATHE_SMOOTH_DEPTH, BREATHE_SMOOTH_DEPTH_X,
BREATHE_SMOOTH_SHAPE, normalize_transform, state_breathe)
from sprite_gen.frames.extract import BORDER_MIN_FRACTION, FRAME_SIDES, own_border, solid_alpha_bbox
from sprite_gen.frames.folder import cycle_frame_ms, open_frames, publish, reference_frame
@@ -202,11 +202,12 @@ def row_strain(anat: Anatomy, depth: float) -> float:
# smooth 의 짝: 쉼(곡선 0)에서 최소, 들숨 꼭대기(곡선 1)에서 최대 — 가슴이 부풀며 오른다.
def _bounds(cfg: dict) -> tuple[tuple[float, float], tuple[float, float]] | None:
- """((가로 최소, 최대), (세로 최소, 최대)) — 줄이 최소·최대 키로 적혔으면(정규화가 네 키를 다 싣는다). 세기 줄은 None."""
- if cfg.get("width_min") is None:
+ """((가로 최소, 최대), (세로 최소, 최대)) — 줄이 최소·최대 키로 적혔으면. 정규화는 네 키를 다 싣지만, 정규화를 거치지
+ 않은 설정도 적지 않은 경계를 0 으로 읽는다 (state_breathe·미러 breatheBounds 와 같다). 세기 줄은 None."""
+ if all(cfg.get(k) is None for k in BREATHE_RANGE_KEYS):
return None
- return ((float(cfg["width_min"]), float(cfg["width_max"])),
- (float(cfg["height_min"]), float(cfg["height_max"])))
+ value = lambda k: 0.0 if cfg.get(k) is None else float(cfg[k])
+ return ((value("width_min"), value("width_max")), (value("height_min"), value("height_max")))
def pixel_gains(anat: Anatomy, cfg: dict) -> tuple[tuple[float, float], tuple[float, float]]:
diff --git a/tests/effects/test_breathe_min_max.py b/tests/effects/test_breathe_min_max.py
index 3c84304..0763fcb 100644
--- a/tests/effects/test_breathe_min_max.py
+++ b/tests/effects/test_breathe_min_max.py
@@ -270,6 +270,15 @@ def test_a_bound_left_out_is_the_original_size() -> None:
assert "depth" not in cfg and "depth_x" not in cfg
+def test_a_bake_handed_part_of_the_keys_reads_the_rest_as_zero() -> None:
+ """정규화를 거치지 않고 굽기에 바로 준 설정도 같다 — 네 키 중 일부만 있으면 나머지는 0 이지 세기 줄이 아니다
+ (큐레이터 미러 breatheBounds 와 같은 읽기)."""
+ src = _humanoid()
+ raw = {"width_max": 0.05, "breaths": 1, "lag": 0.1}
+ for t in (0.25, 0.75):
+ assert B.phase_frame(src, raw, t).tobytes() == B.phase_frame(src, _cfg(raw), t).tobytes()
+
+
def test_the_row_strain_cap_reads_the_extremes() -> None:
"""행당 변형 상한(0.25)은 새 키의 극값으로 잰다 — 가로 극값은 그 자체가 가장 크게 숨쉬는 행의 몫이라 범위
안(0.20 까지)이면 걸리지 않고, 세로 극값은 목 아래 몸통에 고루 나눈 몫이라 변형 구간이 좁은 그림에서 걸린다."""