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) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-04-16 06:53:55 +00:00
parent e7189742bf
commit 0a4f9793e9

View File

@@ -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)