diff --git a/src/atm/detector.py b/src/atm/detector.py index b99e994..f2c3d82 100644 --- a/src/atm/detector.py +++ b/src/atm/detector.py @@ -37,13 +37,19 @@ class Detector: self, cfg: Config, capture: ScreenCapture, - bg_rgb: tuple[int, int, int] = (18, 18, 18), - bg_tol: float = 15.0, + bg_rgb: tuple[int, int, int] | None = None, + bg_tol: float | None = None, ) -> None: self._cfg = cfg self._capture = capture - self._bg_rgb = bg_rgb - self._bg_tol = bg_tol + # Prefer config-defined background; fall back to dark-grey default. + if "background" in cfg.colors: + spec = cfg.colors["background"] + self._bg_rgb = bg_rgb if bg_rgb is not None else spec.rgb + self._bg_tol = bg_tol if bg_tol is not None else spec.tolerance + else: + self._bg_rgb = bg_rgb if bg_rgb is not None else (18, 18, 18) + self._bg_tol = bg_tol if bg_tol is not None else 15.0 # Palette excludes "background" key self._palette: dict[str, tuple[tuple[int, int, int], float]] = { name: (spec.rgb, spec.tolerance)