def test_cubic01_path01_length(self): # See also: cubic01.html d = 'M100,200 C100,100 250,100 250,200 C250,300 400,300 400,200' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 475.7469787597656 # firefox expected = 475.74774169921875 self.assertAlmostEqual(expected, n, places=places) d = 'M100,200 C100,100 250,100 250,200 S400,300 400,200' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 475.7469787597656 # firefox expected = 475.74774169921875 self.assertAlmostEqual(expected, n, places=places)
def test_bearing01_length(self): # See also: bearing01.html d = 'M150,10 B36 h47 b72 h47 b72 h47 b72 h47 Z' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) expected = 235 self.assertAlmostEqual(expected, n)
def test_triangle01_rel_length(self): # See also: triangle01.html d = 'm100,100 l200,0 l-100,200 z' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) expected = 647.213623046875 self.assertAlmostEqual(expected, n, places=places)
def test_vertical_lineto_abs_length(self): path_data = list() path_data.append(SVGPathSegment('M', 50, 50)) path_data.append(SVGPathSegment('V', 150)) n = PathParser.get_total_length(path_data) expected = 100 self.assertEqual(expected, n)
def test_ellipse01_path34_length(self): # See also: ellipse01.html # rx > ry # x_axis_rotation: 0 # large_arc_flag: 0 # sweep_flag: 0 path_data = list() cx = 0 cy = 0 rx = 250 ry = 100 ellipse = Ellipse(cx, cy, rx, ry) cpx, cpy = ellipse.point(0 - 20) path_data.append(SVGPathSegment('M', cpx, cpy)) rotation = 0 fa = 0 fs = 0 epx, epy = ellipse.point(0 + 45) path_data.append( SVGPathSegment('A', rx, ry, rotation, fa, fs, epx, epy)) # -> 'M234.923,34.202 A250,100 0 0 0 176.777,-70.711' n = PathParser.get_total_length(path_data) # expected = 145.73971557617188 # firefox expected = 145.73988342285156 self.assertAlmostEqual(expected, n, places=places)
def test_ellipse01_path22_length(self): # See also: ellipse01.html # ry > rx # x_axis_rotation: 0 # large_arc_flag: 1 # sweep_flag: 1 path_data = list() cx = 0 cy = 0 rx = 100 ry = 250 ellipse = Ellipse(cx, cy, rx, ry) cpx, cpy = ellipse.point(-60) path_data.append(SVGPathSegment('M', cpx, cpy)) rotation = 0 fa = 1 fs = 1 epx, epy = ellipse.point(30) path_data.append( SVGPathSegment('A', rx, ry, rotation, fa, fs, epx, epy)) # d = PathParser.tostring(path_data) # -> "M50,216.506 A100,250 0 1 1 86.603,-125" n = PathParser.get_total_length(path_data) # expected = 799.613037109375 # firefox expected = 799.7357177734375 self.assertAlmostEqual(expected, n, places=places)
def test_ellipse01_path21_length(self): # See also: ellipse01.html # ry > rx # x_axis_rotation: 0 # large_arc_flag: 0 # sweep_flag: 1 path_data = list() cx = 0 cy = 0 rx = 100 ry = 250 ellipse = Ellipse(cx, cy, rx, ry) cpx, cpy = ellipse.point(20) path_data.append(SVGPathSegment('M', cpx, cpy)) rotation = 0 fa = 0 fs = 1 epx, epy = ellipse.point(-45) path_data.append( SVGPathSegment('A', rx, ry, rotation, fa, fs, epx, epy)) # d = PathParser.tostring(path_data) # -> "M93.969,-85.505 A100,250 0 0 1 70.711,176.777" n = PathParser.get_total_length(path_data) # expected = 265.98455810546875 # firefox expected = 265.9847106933594 self.assertAlmostEqual(expected, n, places=places)
def test_vertical_lineto_rel_length(self): path_data = list() path_data.append(SVGPathSegment('m', 50, 50)) path_data.append(SVGPathSegment('v', -50)) n = PathParser.get_total_length(path_data) expected = 50 self.assertEqual(expected, n)
def test_ellipse01_path33_length(self): # See also: ellipse01.html # rx > ry # x_axis_rotation: 0 # large_arc_flag: 0 # sweep_flag: 0 path_data = list() cx = 0 cy = 0 rx = 250 ry = 100 ellipse = Ellipse(cx, cy, rx, ry) cpx, cpy = ellipse.point(270 - 20) path_data.append(SVGPathSegment('M', cpx, cpy)) rotation = 0 fa = 0 fs = 0 epx, epy = ellipse.point(270 + 45) path_data.append( SVGPathSegment('A', rx, ry, rotation, fa, fs, epx, epy)) # -> "M-85.505,93.969 A250,100 0 0 0 176.777,70.711" n = PathParser.get_total_length(path_data) # expected = 265.98455810546875 # firefox # expected = 265.98468017578125 expected = 265.9847106933594 self.assertAlmostEqual(expected, n, places=places)
def test_lineto_rel_length(self): # See also: bearing01.html # "M150,10 B36 h47 b72 h47 b72 h47 b72 h47 Z" path_data = list() path_data.append(SVGPathSegment('m', 150, 10)) path_data.append( SVGPathSegment('l', 38.02379873562253, 27.62590685774624)) path_data.append( SVGPathSegment('l', -14.52379873562252, 44.69965626587222)) path_data.append(SVGPathSegment('l', -47, 0)) path_data.append( SVGPathSegment('l', -14.52379873562254, -44.69965626587221)) path_data.append(SVGPathSegment('z')) d = PathParser.tostring(path_data) expected = "m150,10" \ " l38.023799,27.625907" \ " -14.523799,44.699656" \ " -47,0" \ " -14.523799,-44.699656" \ " z" self.assertEqual(expected, d) n = PathParser.get_total_length(path_data) expected = 235 self.assertAlmostEqual(expected, n)
def test_arcs01_path02_length(self): # See also: arcs01.html d = 'M275,175 v-150 a150,150 0 0,0 -150,150 z' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 535.6527099609375 # firefox expected = 535.652587890625 self.assertAlmostEqual(expected, n, places=places)
def test_arcs02_path04_length(self): # See also: arcs02.html d = 'M 125,75 a100,50 0 1,1 100,50' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 363.3686218261719 # firefox expected = 363.3689880371094 self.assertAlmostEqual(expected, n, places=places)
def test_arcs02_path03_length(self): # See also: arcs02.html d = 'M 125,75 a100,50 0 1,0 100,50' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 363.3684997558594 # firefox expected = 363.36895751953125 self.assertAlmostEqual(expected, n, places=places)
def test_cubic02_01_path04_length(self): # See also: cubic02_01.html d = 'm600,200 c75,-100 375,-100 300,0' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 383.4436340332031 # firefox expected = 383.4443664550781 self.assertAlmostEqual(expected, n, places=places)
def test_arcs01_path04_length(self): # See also: arcs01.html d = 'M950,175 a25,100 0 0,1 50,-25' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 216.15928649902344 # firefox expected = 215.92034912109375 self.assertAlmostEqual(expected, n, places=places)
def test_cubic02_path01_length(self): # See also: cubic02.html d = 'M100,200 C100,100 400,100 400,200' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 366.38275146484375 # firefox expected = 366.3829650878906 self.assertAlmostEqual(expected, n, places=places)
def test_quad02_path03_length(self): # See also: quad02.html d = 'm200,300 q200,-250 400,0 t400,0 400,0' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 1463.3150634765625 # firefox expected = 1463.3143310546875 self.assertAlmostEqual(expected, n, places=places)
def test_quad02_path02_length(self): # See also: quad02.html d = 'M200,300 Q400,50 600,300 Q800,550 1000,300 Q1200,50 1400,300' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 1463.3150634765625 # firefox expected = 1463.3143310546875 self.assertAlmostEqual(expected, n, places=places)
def test_quad01_path02_length(self): # See also: quad01.html d = 'M200,300 Q400,50 600,300' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 487.7709655761719 # firefox expected = 487.77130126953125 self.assertAlmostEqual(expected, n, places=places)
def test_cubic01_path02_length(self): # See also: cubic01.html d = 'M100,200 C100,100 250,100 250,200' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 237.87351989746094 # firefox expected = 237.87376403808594 self.assertAlmostEqual(expected, n, places=places)
def test_quad01_path01_length(self): # See also: quad01.html d = 'M200,300 Q400,50 600,300 T1000,300' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 975.5421142578125 # firefox expected = 975.542724609375 self.assertAlmostEqual(expected, n, places=places)
def test_arcs02_path02_length(self): # See also: arcs02.html d = 'M 125,75 a100,50 0 0,1 100,50' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 121.12287139892578 # firefox expected = 121.12297821044922 self.assertAlmostEqual(expected, n, places=places)
def test_cubic02_01_path05_length(self): # See also: cubic02_01.html d = 'm600,500 c0,-150 300,150 300,0' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 375.2682189941406 # firefox expected = 375.26849365234375 self.assertAlmostEqual(expected, n, places=places)
def test_arcs01_path05_length(self): # See also: arcs01.html d = 'M950,175 a25,100 -30 0,1 50,-25' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 239.37266540527344 # firefox expected = 239.39996337890625 self.assertAlmostEqual(expected, n, places=places)
def test_cubic02_01_path02_length(self): # See also: cubic02_01.html d = 'm100,500 c-75,-100 375,-100 300,0' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 403.0122985839844 # firefox expected = 403.01336669921875 self.assertAlmostEqual(expected, n, places=places)
def test_arcs02_path01_length(self): # See also: arcs02.html d = 'M 125,75 a100,50 0 0,0 100,50' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 121.12281799316406 # firefox expected = 121.12298583984375 self.assertAlmostEqual(expected, n, places=places)
def test_cubic02_01_path03_length(self): # See also: cubic02_01.html d = 'm100,800 c75,-100 225,-100 300,0' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 347.868408203125 # firefox expected = 347.8686828613281 self.assertAlmostEqual(expected, n, places=places)
def test_arcs01_path01_length(self): # See also: arcs01.html d = 'M300,200 h-150 a150,150 0 1,0 150,-150 z' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 1006.957763671875 # firefox expected = 1006.9581298828125 self.assertAlmostEqual(expected, n, places=places)
def test_cubic02_path06_length(self): # See also: cubic02.html d = 'M600,800 C625,700 725,700 750,800 S875,900 900,800' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 457.373046875 # firefox expected = 457.37384033203125 self.assertAlmostEqual(expected, n, places=places)
def test_cubic03_path04_length(self): # See also: cubic03.html # "m" "c" "s" "s" -> "m" "c" "c" d = 'm575,200 c20,100 50,100 70,0 20,-100 55,-100 75,0' path_data = PathParser.parse(d) n = PathParser.get_total_length(path_data) # expected = 348.3697204589844 # firefox expected = 348.37030029296875 self.assertAlmostEqual(expected, n, places=places)