コード例 #1
0
    def shortenpath(self, dists):
        """shortens a path by the given distances"""

        # XXX later, this should be done by extended boxes instead of intersecting with circles
        # cut off the start of self
        center = self.atbegin_pt()
        cutpath = path.circle_pt(center[0], center[1], dists[0])
        try:
            cutpath = cutpath.normpath()
        except normpath.NormpathException:
            pass
        else:
            sp = self.intersect(cutpath)[0]
            self.normsubpaths = self.split(sp[-1:])[1].normsubpaths

        # cut off the end of self
        center = self.atend_pt()
        cutpath = path.circle_pt(center[0], center[1], dists[1])
        try:
            cutpath = cutpath.normpath()
        except normpath.NormpathException:
            pass
        else:
            sp = self.intersect(cutpath)[0]
            if sp:
                self.normsubpaths = self.split(sp[:1])[0].normsubpaths
コード例 #2
0
 def decorate(self, dp, texrunner):
     r_pt = 2
     dp.ensurenormpath()
     for normsubpath in dp.path.normsubpaths:
         for i, normsubpathitem in enumerate(normsubpath.normsubpathitems):
             if isinstance(normsubpathitem, normpath.normcurve_pt):
                 dp.ornaments.stroke(
                     normpath.normpath(
                         [normpath.normsubpath([normsubpathitem])]),
                     [color.rgb.green])
             else:
                 dp.ornaments.stroke(
                     normpath.normpath(
                         [normpath.normsubpath([normsubpathitem])]),
                     [color.rgb.blue])
     for normsubpath in dp.path.normsubpaths:
         for i, normsubpathitem in enumerate(normsubpath.normsubpathitems):
             if isinstance(normsubpathitem, normpath.normcurve_pt):
                 dp.ornaments.stroke(
                     path.line_pt(normsubpathitem.x0_pt,
                                  normsubpathitem.y0_pt,
                                  normsubpathitem.x1_pt,
                                  normsubpathitem.y1_pt),
                     [style.linestyle.dashed, color.rgb.red])
                 dp.ornaments.stroke(
                     path.line_pt(normsubpathitem.x2_pt,
                                  normsubpathitem.y2_pt,
                                  normsubpathitem.x3_pt,
                                  normsubpathitem.y3_pt),
                     [style.linestyle.dashed, color.rgb.red])
                 dp.ornaments.draw(
                     path.circle_pt(normsubpathitem.x1_pt,
                                    normsubpathitem.y1_pt, r_pt),
                     [filled([color.rgb.red])])
                 dp.ornaments.draw(
                     path.circle_pt(normsubpathitem.x2_pt,
                                    normsubpathitem.y2_pt, r_pt),
                     [filled([color.rgb.red])])
     for normsubpath in dp.path.normsubpaths:
         for i, normsubpathitem in enumerate(normsubpath.normsubpathitems):
             if not i:
                 x_pt, y_pt = normsubpathitem.atbegin_pt()
                 dp.ornaments.draw(path.circle_pt(x_pt, y_pt, r_pt),
                                   [filled])
             x_pt, y_pt = normsubpathitem.atend_pt()
             dp.ornaments.draw(path.circle_pt(x_pt, y_pt, r_pt), [filled])
コード例 #3
0
ファイル: deco.py プロジェクト: asuar078/python_workspace
 def decorate(self, dp, texrunner):
     r_pt = 2
     dp.ensurenormpath()
     for normsubpath in dp.path.normsubpaths:
         for i, normsubpathitem in enumerate(normsubpath.normsubpathitems):
             if isinstance(normsubpathitem, normpath.normcurve_pt):
                 dp.ornaments.stroke(normpath.normpath([normpath.normsubpath([normsubpathitem])]), [color.rgb.green])
             else:
                 dp.ornaments.stroke(normpath.normpath([normpath.normsubpath([normsubpathitem])]), [color.rgb.blue])
     for normsubpath in dp.path.normsubpaths:
         for i, normsubpathitem in enumerate(normsubpath.normsubpathitems):
             if isinstance(normsubpathitem, normpath.normcurve_pt):
                 dp.ornaments.stroke(path.line_pt(normsubpathitem.x0_pt, normsubpathitem.y0_pt, normsubpathitem.x1_pt, normsubpathitem.y1_pt), [style.linestyle.dashed, color.rgb.red])
                 dp.ornaments.stroke(path.line_pt(normsubpathitem.x2_pt, normsubpathitem.y2_pt, normsubpathitem.x3_pt, normsubpathitem.y3_pt), [style.linestyle.dashed, color.rgb.red])
                 dp.ornaments.draw(path.circle_pt(normsubpathitem.x1_pt, normsubpathitem.y1_pt, r_pt), [filled([color.rgb.red])])
                 dp.ornaments.draw(path.circle_pt(normsubpathitem.x2_pt, normsubpathitem.y2_pt, r_pt), [filled([color.rgb.red])])
     for normsubpath in dp.path.normsubpaths:
         for i, normsubpathitem in enumerate(normsubpath.normsubpathitems):
             if not i:
                 x_pt, y_pt = normsubpathitem.atbegin_pt()
                 dp.ornaments.draw(path.circle_pt(x_pt, y_pt, r_pt), [filled])
             x_pt, y_pt = normsubpathitem.atend_pt()
             dp.ornaments.draw(path.circle_pt(x_pt, y_pt, r_pt), [filled])