From 0a4f9793e95dadaaa41fec8b776817eb1676e302 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Thu, 16 Apr 2026 06:53:55 +0000 Subject: [PATCH] fix(detector): source bg_rgb/bg_tol from cfg.colors.background when present User's chart background is pure black (0,0,0) but detector hardcoded (18,18,18) with tol=15. Gap pixels between dots (0,0,0) fell outside background tolerance, so find_rightmost_dot locked onto a gap pixel rather than a dot. Now falls back to the config's background spec if defined. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/atm/detector.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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)