Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

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>
Changeset3dfaecc53bd046ae08ef0cf39d625583dc7e70b4
Author (claimed)Timo Stolz <timo.stolz@nullachtvierzehn.de>,
Parents9c1385fb03b5
Childrenb63856393ea3
Pushlog
by timo via ssh
by timo via ssh

modified schach/diagram.py +20 −4

@@ -247,7 +247,6 @@ class BoardPainter:
247247
                 self._mark(cr, s, sq, THREAT)
248248
         if self.spotlight is not None and self.spotlight_from is not None:
249249
             self._glow(cr, self.spotlight_from, sq, SPOTLIGHT, 0.8)
250
-            self._mark(cr, self.spotlight, sq, SPOTLIGHT)
251250
         elif self.spotlight is not None:
252251
             # Spalte und Zeile blass, das Feld im Schnittpunkt kräftig: so liest man Koordinaten
253252
             file, rank = chess.square_file(self.spotlight), chess.square_rank(self.spotlight)
@@ -257,7 +256,6 @@ class BoardPainter:
257256
                     x, y = self._square_origin(s)
258257
                     cr.rectangle(x, y, sq, sq)
259258
             cr.fill()
260
-            self._mark(cr, self.spotlight, sq, SPOTLIGHT)
261259
 
262260
         self._draw_coordinates(cr, sq)
263261
 
@@ -296,8 +294,10 @@ class BoardPainter:
296294
 
297295
         if self.threat_from is not None and self.threat_to is not None:
298296
             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)
301301
         for tail, head, color in self.shapes:
302302
             rgb = SHAPE_COLORS.get(color, SHAPE_COLORS["green"])
303303
             if tail == head:
@@ -345,6 +345,22 @@ class BoardPainter:
345345
         cr.rectangle(x + inset, y + inset, sq - 2 * inset, sq - 2 * inset)
346346
         cr.stroke()
347347
 
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
+
348364
     def _ring(self, cr, square, sq, rgb):
349365
         """Markiertes Feld: Kreis wie bei Lichess."""
350366
         x, y = self._square_origin(square)