Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarize committed May 14, 2023
2 parents 4f1934d + 3703393 commit 212ca03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions svgelements/svgelements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3801,6 +3801,7 @@ def npoint(self, positions, error=ERROR):
position_subset = (segment_start <= positions) & (positions < segment_end)
v0 = positions[position_subset]
if not len(v0):
segment_start = segment_end
continue # Nothing matched.
d = segment_end - segment_start
if d == 0: # This segment is 0 length.
Expand Down
12 changes: 12 additions & 0 deletions test/test_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,18 @@ def test_shape_npoints_len0(self):
for p, p1, p2 in zip(pos, v1, v2):
self.assertEqual(Point(p1), Point(p2))

def test_shape_npoints_points_issue_232(self):
import numpy as np
p = Path("M 4594.76424273,1787.94321633 C 4582.20211202,1787.86035528 4571.02257722,1787.8800841 4561.51723033,1788.01029433 C 4552.01148887,1788.14050456 4544.17164921,1788.39697926 4538.36624578,1788.75801672 C 4532.56044777,1789.12102706 4528.29783829,1789.91017998 4528.13803482,1789.96778814 C 4499.59674127,1800.20732345 4482.59365252,1807.33408452 4460.51078644,1822.22520278 C 4427.94718047,1844.1833827 4410.22517341,1855.51652611 4388.9239633,1876.84176593 C 4370.029275,1895.75784027 4345.39705043,1930.28225449 4336.63903135,1945.92081894 C 4328.01122251,1961.3264649 4304.48815236,2015.51609632 4294.15340576,2054.0867343 C 4287.16979702,2080.14929854 4284.79681419,2117.73112791 4281.09884363,2145.82220972 C 4279.62312767,2157.03133775 4279.82436166,2175.09268056 4280.27417883,2189.42961619 L 4289.87540779,2190.26611828 L 4288.916587,2201.39633102 L 4280.67901427,2200.68214763 C 4280.91576015,2206.22200111 4281.14066873,2210.21748233 4281.14066873,2210.21748233 L 4281.14066873,2210.4542282 L 4261.31122881,2937.51619918 L 4861.38942017,2992.84765596 L 4862.09176627,2532.61051811 L 4862.2890545,2532.61051811 L 4862.21013921,2529.7932422 C 4839.05994381,2460.37146008 4825.96039996,2381.42736429 4825.96039996,2297.62366484 C 4825.96039996,2280.80523787 4826.50491547,2264.18449371 4827.53476003,2247.79102559 L 4766.64924502,2242.54513157 L 4767.60412005,2231.44806325 L 4828.39059637,2236.6833037 C 4837.10876322,2123.48957674 4869.70590819,2021.87587968 4918.36586621,1944.8818202 C 4964.40228536,1872.03854724 5025.02659075,1821.03997401 5093.12575258,1803.84228015 C 5038.09614679,1801.52256515 4954.58680138,1798.09673397 4850.52988688,1794.49385632 C 4773.90550609,1791.84072421 4696.39174997,1789.49224459 4636.28670719,1788.46693766 C 4621.2604465,1788.21046297 4607.32006022,1788.02185542 4594.75792951,1787.93899436 L 4594.76424273,1787.94321633")
space = np.linspace(0, 1, 101)
points = p.npoint(space)
for n in range(len(space)):
npoint = points[n]
point = p.point(space[n])

self.assertAlmostEqual(npoint[0], point[0])
self.assertAlmostEqual(npoint[1], point[1])


def reification_checks(test, shape):
correct_reify(test, shape * "rotate(-90) translate(20,0)")
Expand Down

0 comments on commit 212ca03

Please sign in to comment.