Skip to content

Commit

Permalink
Correct first point and orientation of Kiva QPainter arcs (#970)
Browse files Browse the repository at this point in the history
* Correct first point and orientation of Kiva QPainter arcs.

This fixes #962 but not #960.

* Update kiva/qpainter.py
  • Loading branch information
corranwebster committed Aug 8, 2022
1 parent e62f176 commit 8f011c2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kiva/qpainter.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,16 @@ def arc(self, x, y, r, start_angle, end_angle, clockwise=False):
if not clockwise
else start_angle - end_angle
)
self.path.moveTo(x, y)
if self.is_empty():
# if this is the first point of the path, don't draw a line
# to the start point
self.path.moveTo(
x + r * np.cos(start_angle),
y + r * np.sin(start_angle),
)
# draw arc flipped in y-axis because QPainter has top-left origin
self.path.arcTo(
QtCore.QRectF(x - r, y - r, r * 2, r * 2),
QtCore.QRectF(x - r, y + r, r * 2, -r * 2),
np.rad2deg(start_angle),
np.rad2deg(sweep_angle),
)
Expand Down

0 comments on commit 8f011c2

Please sign in to comment.