Skip to content

Commit

Permalink
Correct inverted rounded rect.
Browse files Browse the repository at this point in the history
If the rx is negative and so is the width, the rectangle is normal, but mirrored and should maintain its corners.
  • Loading branch information
tatarize committed Jun 7, 2021
1 parent be2c0b8 commit 74fe682
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 5 additions & 6 deletions svgelements/svgelements.py
Original file line number Diff line number Diff line change
Expand Up @@ -4697,7 +4697,7 @@ def __init__(self, *args, **kwargs):
if "scooped" in kwargs and kwargs["scooped"]:
self.sweep = -self.sweep
cw = not cw
if "ccw" in kwargs and kwargs["ccw"] and cw or not cw:
if ("ccw" in kwargs and kwargs["ccw"] and cw) or not cw:
self.center = Point(self.end.x, self.start.y)

if self.center is None:
Expand Down Expand Up @@ -6248,13 +6248,12 @@ def segments(self, transformed=True):
rx = self.rx
ry = self.ry
if not self._strict:
if rx < 0 and ry < 0:
if rx < 0 < width and ry < 0 < height:
scooped = True
rx = abs(rx)
ry = abs(ry)
if rx < 0:
rx = abs(rx)
ry = abs(ry)
if rx < 0 < width or ry < 0 < height:
rx = 0
if ry < 0:
ry = 0
if rx == ry == 0:
segments = (
Expand Down
4 changes: 4 additions & 0 deletions test/test_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ def test_rect_strict(self):
e3._strict = False # unstrict rx-negative rectangles, have scooped corners.
self.assertNotEqual(e3, e2)

values['ry'] = 4
e4 = Rect(values)
self.assertEqual(e, e4)

def test_shape_npoints(self):
import numpy as np
shapes = [
Expand Down

0 comments on commit 74fe682

Please sign in to comment.