style(board): crosshair corners mark the hovered target square
public
style(board): crosshair corners mark the hovered target square Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Changeset | 3dfaecc53bd046ae08ef0cf39d625583dc7e70b4 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@nullachtvierzehn.de>, |
| Parents | 9c1385fb03b5 |
| Children | b63856393ea3 |
| Pushlog | by timo via ssh by timo via ssh |
modified schach/diagram.py +20 −4
| @@ -247,7 +247,6 @@ class BoardPainter: | ||
| 247 | 247 | self._mark(cr, s, sq, THREAT) |
| 248 | 248 | if self.spotlight is not None and self.spotlight_from is not None: |
| 249 | 249 | self._glow(cr, self.spotlight_from, sq, SPOTLIGHT, 0.8) |
| 250 | - self._mark(cr, self.spotlight, sq, SPOTLIGHT) | |
| 251 | 250 | elif self.spotlight is not None: |
| 252 | 251 | # Spalte und Zeile blass, das Feld im Schnittpunkt kräftig: so liest man Koordinaten |
| 253 | 252 | file, rank = chess.square_file(self.spotlight), chess.square_rank(self.spotlight) |
| @@ -257,7 +256,6 @@ class BoardPainter: | ||
| 257 | 256 | x, y = self._square_origin(s) |
| 258 | 257 | cr.rectangle(x, y, sq, sq) |
| 259 | 258 | cr.fill() |
| 260 | - self._mark(cr, self.spotlight, sq, SPOTLIGHT) | |
| 261 | 259 | |
| 262 | 260 | self._draw_coordinates(cr, sq) |
| 263 | 261 | |
| @@ -296,8 +294,10 @@ class BoardPainter: | ||
| 296 | 294 | |
| 297 | 295 | if self.threat_from is not None and self.threat_to is not None: |
| 298 | 296 | self._draw_arrow(cr, self.threat_from, self.threat_to, sq, THREAT) |
| 299 | - if self.spotlight is not None and self.spotlight_from is not None: | |
| 300 | - self._draw_arrow(cr, self.spotlight_from, self.spotlight, sq, SPOTLIGHT) | |
| 297 | + if self.spotlight is not None: | |
| 298 | + if self.spotlight_from is not None: | |
| 299 | + self._draw_arrow(cr, self.spotlight_from, self.spotlight, sq, SPOTLIGHT) | |
| 300 | + self._crosshair(cr, self.spotlight, sq, SPOTLIGHT) | |
| 301 | 301 | for tail, head, color in self.shapes: |
| 302 | 302 | rgb = SHAPE_COLORS.get(color, SHAPE_COLORS["green"]) |
| 303 | 303 | if tail == head: |
| @@ -345,6 +345,22 @@ class BoardPainter: | ||
| 345 | 345 | cr.rectangle(x + inset, y + inset, sq - 2 * inset, sq - 2 * inset) |
| 346 | 346 | cr.stroke() |
| 347 | 347 | |
| 348 | + def _crosshair(self, cr, square, sq, rgb): | |
| 349 | + """Zielfeld wie im Visier: vier Kreisbögen in den Ecken, die Figur bleibt frei.""" | |
| 350 | + x, y = self._square_origin(square) | |
| 351 | + cx, cy = x + sq / 2, y + sq / 2 | |
| 352 | + cr.save() | |
| 353 | + cr.set_line_cap(cairo.LINE_CAP_ROUND) | |
| 354 | + for width, color in ((sq * 0.11, (0, 0, 0, 0.35)), (sq * 0.07, (*rgb, 1.0))): # dunkler Rand: auf jedem Feld sichtbar | |
| 355 | + cr.set_source_rgba(*color) | |
| 356 | + cr.set_line_width(width) | |
| 357 | + for corner in range(4): | |
| 358 | + middle = math.pi / 4 + corner * math.pi / 2 | |
| 359 | + cr.new_path() | |
| 360 | + cr.arc(cx, cy, sq * 0.44, middle - 0.42, middle + 0.42) | |
| 361 | + cr.stroke() | |
| 362 | + cr.restore() | |
| 363 | + | |
| 348 | 364 | def _ring(self, cr, square, sq, rgb): |
| 349 | 365 | """Markiertes Feld: Kreis wie bei Lichess.""" |
| 350 | 366 | x, y = self._square_origin(square) |