fix: Torte – große Segmente als zwei Teilbögen (A13-T3)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
Beträge und Anteile bleiben Decimal; nur die Geometrie (Winkel, SVG-
|
||||
Koordinaten im Einheitskreis) rechnet mit float. Start 12 Uhr, im
|
||||
Uhrzeigersinn (SVG-y zeigt nach unten).
|
||||
Uhrzeigersinn (SVG-y zeigt nach unten). Große Segmente (> 50 %) werden als
|
||||
zwei Teilbögen durch Mittelpunkt gezogen, um Rundungsfehler zu vermeiden.
|
||||
"""
|
||||
import math
|
||||
from dataclasses import dataclass
|
||||
@@ -35,8 +36,13 @@ def _point(fraction: float) -> tuple[float, float]:
|
||||
def _arc(start: float, end: float) -> str:
|
||||
x0, y0 = _point(start)
|
||||
x1, y1 = _point(end)
|
||||
large = 1 if end - start > 0.5 else 0
|
||||
return f"M 0 0 L {x0:.4f} {y0:.4f} A 1 1 0 {large} 1 {x1:.4f} {y1:.4f} Z"
|
||||
if end - start > 0.5:
|
||||
# Großes Segment: zwei Teilbögen durch Mittelpunkt, um Rundungsfehler zu vermeiden
|
||||
mid = (start + end) / 2
|
||||
xm, ym = _point(mid)
|
||||
return f"M 0 0 L {x0:.4f} {y0:.4f} A 1 1 0 0 1 {xm:.4f} {ym:.4f} A 1 1 0 0 1 {x1:.4f} {y1:.4f} Z"
|
||||
else:
|
||||
return f"M 0 0 L {x0:.4f} {y0:.4f} A 1 1 0 0 1 {x1:.4f} {y1:.4f} Z"
|
||||
|
||||
|
||||
def pie_slices(values: list[tuple[str, Decimal]], rest: Decimal | None = None,
|
||||
|
||||
Reference in New Issue
Block a user