style(board): outlined hover arrow drawn above the crosshair
public
style(board): outlined hover arrow drawn above the crosshair Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Changeset | fb734551cbe2470b31b682eec590f46a353e6366 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@nullachtvierzehn.de>, |
| Parents | b63856393ea3 |
| Children | 6e7d3a949184 |
| Pushlog | by timo via ssh by timo via ssh |
modified schach/diagram.py +24 −15
| @@ -295,9 +295,9 @@ class BoardPainter: | ||
| 295 | 295 | if self.threat_from is not None and self.threat_to is not None: |
| 296 | 296 | self._draw_arrow(cr, self.threat_from, self.threat_to, sq, THREAT) |
| 297 | 297 | if self.spotlight is not None: |
| 298 | + self._crosshair(cr, self.spotlight, sq, SPOTLIGHT) | |
| 298 | 299 | 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) | |
| 300 | + self._draw_arrow(cr, self.spotlight_from, self.spotlight, sq, SPOTLIGHT, outline=True) | |
| 301 | 301 | for tail, head, color in self.shapes: |
| 302 | 302 | rgb = SHAPE_COLORS.get(color, SHAPE_COLORS["green"]) |
| 303 | 303 | if tail == head: |
| @@ -370,7 +370,8 @@ class BoardPainter: | ||
| 370 | 370 | cr.arc(x + sq / 2, y + sq / 2, sq * 0.42, 0, 2 * math.pi) |
| 371 | 371 | cr.stroke() |
| 372 | 372 | |
| 373 | - def _draw_arrow(self, cr, src, dst, sq, rgb): | |
| 373 | + def _draw_arrow(self, cr, src, dst, sq, rgb, outline=False): | |
| 374 | + """Pfeil von Feld zu Feld; ``outline``: deckend mit dunklem Rand, hebt sich von allem darunter ab.""" | |
| 374 | 375 | x0, y0 = self._square_origin(src) |
| 375 | 376 | x1, y1 = self._square_origin(dst) |
| 376 | 377 | x0, y0, x1, y1 = x0 + sq / 2, y0 + sq / 2, x1 + sq / 2, y1 + sq / 2 |
| @@ -378,19 +379,27 @@ class BoardPainter: | ||
| 378 | 379 | head = sq * 0.38 |
| 379 | 380 | tip_x, tip_y = x1 - math.cos(angle) * sq * 0.12, y1 - math.sin(angle) * sq * 0.12 |
| 380 | 381 | base_x, base_y = tip_x - math.cos(angle) * head * 0.8, tip_y - math.sin(angle) * head * 0.8 |
| 381 | - cr.new_path() | |
| 382 | - cr.set_source_rgba(*rgb, 0.8) | |
| 383 | - cr.set_line_width(sq * 0.13) | |
| 382 | + start_x, start_y = x0 + math.cos(angle) * sq * 0.2, y0 + math.sin(angle) * sq * 0.2 | |
| 383 | + passes = [((0, 0, 0, 0.45), sq * 0.04), ((*rgb, 1.0), 0)] if outline else [((*rgb, 0.8), 0)] | |
| 384 | + cr.save() | |
| 384 | 385 | cr.set_line_cap(cairo.LINE_CAP_ROUND) |
| 385 | - cr.move_to(x0 + math.cos(angle) * sq * 0.2, y0 + math.sin(angle) * sq * 0.2) | |
| 386 | - cr.line_to(base_x, base_y) | |
| 387 | - cr.stroke() | |
| 388 | - cr.move_to(tip_x, tip_y) | |
| 389 | - for side in (-0.5, 0.5): | |
| 390 | - cr.line_to(tip_x - head * math.cos(angle + side), tip_y - head * math.sin(angle + side)) | |
| 391 | - cr.close_path() | |
| 392 | - cr.fill() | |
| 393 | - cr.set_line_cap(cairo.LINE_CAP_BUTT) | |
| 386 | + cr.set_line_join(cairo.LINE_JOIN_ROUND) | |
| 387 | + for color, grow in passes: | |
| 388 | + cr.set_source_rgba(*color) | |
| 389 | + cr.new_path() | |
| 390 | + cr.set_line_width(sq * 0.13 + 2 * grow) | |
| 391 | + cr.move_to(start_x, start_y) | |
| 392 | + cr.line_to(base_x, base_y) | |
| 393 | + cr.stroke() | |
| 394 | + cr.move_to(tip_x, tip_y) | |
| 395 | + for side in (-0.5, 0.5): | |
| 396 | + cr.line_to(tip_x - head * math.cos(angle + side), tip_y - head * math.sin(angle + side)) | |
| 397 | + cr.close_path() | |
| 398 | + if grow: | |
| 399 | + cr.set_line_width(2 * grow) | |
| 400 | + cr.stroke_preserve() | |
| 401 | + cr.fill() | |
| 402 | + cr.restore() | |
| 394 | 403 | |
| 395 | 404 | def _fill_square(self, cr, square, sq, rgba): |
| 396 | 405 | x, y = self._square_origin(square) |