Exemple #1
0
    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)
Exemple #2
0
 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)
Exemple #3
0
 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)
Exemple #4
0
 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)
Exemple #5
0
 def test_path_normalize04(self):
     # angle: 270 to 360
     d = 'M0,100 A100,100 0 0 0 100,0'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     exp = PathParser.tostring(normalized)
     expected = 'M0,100 C55.228,100 100,55.228 100,0'
     self.assertEqual(expected, exp)
Exemple #6
0
 def test_path_normalize02(self):
     # angle: 90 to 180
     d = 'M0,-100 A100,100 0 0 0 -100,0'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     exp = PathParser.tostring(normalized)
     expected = 'M0,-100 C-55.228,-100 -100,-55.228 -100,0'
     self.assertEqual(expected, exp)
Exemple #7
0
 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)
Exemple #8
0
 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)
Exemple #9
0
 def test_cubic01_path01_normalize(self):
     # See also: cubic01.html
     d = 'M100,200 C100,100 250,100 250,200 S400,300 400,200'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     d = PathParser.tostring(normalized)
     expected = 'M100,200 C100,100 250,100 250,200 250,300 400,300 400,200'
     self.assertEqual(expected, d)
Exemple #10
0
 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)
Exemple #11
0
 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)
Exemple #12
0
 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)
Exemple #13
0
 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)
Exemple #14
0
 def test_cubic02_path06_normalize(self):
     # See also: cubic02.html
     d = 'M600,800 C625,700 725,700 750,800 S875,900 900,800'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     d = PathParser.tostring(normalized)
     expected = 'M600,800 C625,700 725,700 750,800 775,900 875,900 900,800'
     self.assertEqual(expected, d)
Exemple #15
0
 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)
Exemple #16
0
 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)
Exemple #17
0
 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)
Exemple #18
0
 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)
Exemple #19
0
 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)
Exemple #20
0
 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)
Exemple #21
0
 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)
Exemple #22
0
 def test_path_normalize03(self):
     # angle: 180 to 270
     d = 'M-100,0 A100,100 0 0 0 0,100'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     exp = PathParser.tostring(normalized)
     expected = 'M-100,0 C-100,55.228 -55.228,100 0,100'
     self.assertEqual(expected, exp)
Exemple #23
0
 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)
Exemple #24
0
 def test_path_normalize05(self):
     # angle: 0 to 30
     d = 'M100,0 A100,100 0 0 0 86.60254037844388,-49.99999999999999'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     exp = PathParser.tostring(normalized)
     expected = 'M100,0 C100,-17.554 95.379,-34.798 86.603,-50'
     self.assertEqual(expected, exp)
Exemple #25
0
 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)
Exemple #26
0
 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)
Exemple #27
0
 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)
Exemple #28
0
 def test_triangle01_rel_normalize(self):
     # See also: triangle01.html
     d = 'm100,100 l200,0 l-100,200 z'
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     d = PathParser.tostring(normalized)
     expected = 'M100,100 L300,100 200,300 Z'
     self.assertEqual(expected, d)
Exemple #29
0
 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)
Exemple #30
0
 def test_path_normalize09(self):
     # angle: -30 to 30
     d = "M86.60254037844383,50.00000000000004" \
         " A100,100 0 0 0 86.60254037844388,-49.99999999999999"
     path_data = PathParser.parse(d)
     normalized = PathParser.normalize(path_data)
     exp = PathParser.tostring(normalized)
     expected = 'M86.603,50 C104.466,19.06 104.466,-19.06 86.603,-50'
     self.assertEqual(expected, exp)