Esempio n. 1
0
 def test_closing(self):
     """Closing paths create two arrays"""
     path = Path("M 0,0 C 1.505,0 2.727,-0.823 2.727,-1.841 V -4.348 C 2.727,-5.363"\
                 " 1.505,-6.189 0,-6.189 H -8.3 V 0 Z m -10.713,1.991 h -0.211 V -8.178"\
                 " H 0 c 2.954,0 5.345,1.716 5.345,3.83 v 2.507 C 5.345,0.271 2.954,1.991"
                 " 0,1.991 Z")
     csp = path.to_superpath()
     self.assertEqual(len(csp), 2)
Esempio n. 2
0
 def test_closing_without_z(self):
     """Closing paths without z create two arrays"""
     path = Path("m 51.553104,253.58572 c -11.644086,-0.14509 -4.683516,-19.48876"\
                 " 2.096523,-8.48973 1.722993,2.92995 0.781608,6.73867 -2.096523,8.48973"\
                 " m -3.100522,-13.02176 c -18.971587,17.33811 15.454875,20.05577"\
                 " 6.51412,3.75474 -1.362416,-2.30812 -3.856221,-3.74395 -6.51412,-3.75474")
     csp = path.to_superpath()
     self.assertEqual(len(csp), 2)
def getTranslatedPath(d, posX, posY):
    if(CommonDefs.inkVer == 1.0):
        path = Path(d)
        path.translate(posX, posY, inplace = True)
        return path.to_superpath().__str__()
    else:
        path = simplepath.parsePath(d)
        simplepath.translatePath(path, posX, posY)
        return simplepath.formatPath(path)
Esempio n. 4
0
 def test_is_line(self):
     """Test is super path segments can detect lines"""
     path = Path("m 49,88 70,-1 c 18,17 1,59 1.7,59 "\
                 "0,0 -48.7,18 -70.5,-1 18,-15 25,-32.4 -1.5,-57.2 z")
     csp = path.to_superpath()
     self.assertTrue(csp.is_line(csp[0][0], csp[0][1]), "Should be a line")
     self.assertFalse(csp.is_line(csp[0][3], csp[0][4]),
                      "Both controls not detected")
     self.assertFalse(csp.is_line(csp[0][1], csp[0][2]),
                      "Start control not detected")
     self.assertFalse(csp.is_line(csp[0][2], csp[0][3]),
                      "End control not detected")
     # Also tests if zone close is applied correctly.
     self.assertEqual(str(csp.to_path()), "M 49 88 L 119 87 C 137 104 120 146 120.7 146 "\
         "C 120.7 146 72 164 50.2 145 C 68.2 130 75.2 112.6 48.7 87.8 Z")