コード例 #1
0
ファイル: pattern.py プロジェクト: dcf21/pyxplot7
 def __init__(self, dist, angle, strokestyles=[]):
     pattern.__init__(self, painttype=1, tilingtype=1, xstep=dist, ystep=100*unit.t_pt, bbox=None, trafo=trafo.rotate(angle))
     self.strokestyles = attr.mergeattrs([style.linewidth.THIN] + strokestyles)
     attr.checkattrs(self.strokestyles, [style.strokestyle])
     self.dist = dist
     self.angle = angle
     self.stroke(path.line_pt(0, -50, 0, 50), self.strokestyles)
コード例 #2
0
ファイル: canvas.py プロジェクト: Bhanditz/esl-sent-anal
    def draw(self, path, attrs):
        """draw path on canvas using the style given by args

        The argument attrs consists of PathStyles, which modify
        the appearance of the path, PathDecos, which add some new
        visual elements to the path, or trafos, which are applied
        before drawing the path.

        """

        attrs = attr.mergeattrs(attrs)
        attr.checkattrs(attrs, [
            deco.deco, deformer.deformer, style.fillstyle, style.strokestyle,
            style.fillrule
        ])

        for adeformer in attr.getattrs(attrs, [deformer.deformer]):
            path = adeformer.deform(path)

        styles = attr.getattrs(attrs, [style.fillstyle, style.strokestyle])
        fillrule, = attr.getattrs(
            attrs, [style.fillrule]) or [style.fillrule.nonzero_winding]
        dp = deco.decoratedpath(path, styles=styles, fillrule=fillrule)

        # add path decorations and modify path accordingly
        for adeco in attr.getattrs(attrs, [deco.deco]):
            adeco.decorate(dp, self.texrunner)

        self.insert(dp)
コード例 #3
0
ファイル: canvas.py プロジェクト: epavlick/esl-sent-anal
    def draw(self, path, attrs):
        """draw path on canvas using the style given by args

        The argument attrs consists of PathStyles, which modify
        the appearance of the path, PathDecos, which add some new
        visual elements to the path, or trafos, which are applied
        before drawing the path.

        """

        attrs = attr.mergeattrs(attrs)
        attr.checkattrs(attrs, [deco.deco, deformer.deformer, style.fillstyle, style.strokestyle, style.fillrule])

        for adeformer in attr.getattrs(attrs, [deformer.deformer]):
            path = adeformer.deform(path)

        styles = attr.getattrs(attrs, [style.fillstyle, style.strokestyle])
        fillrule, = attr.getattrs(attrs, [style.fillrule]) or [style.fillrule.nonzero_winding]
        dp = deco.decoratedpath(path, styles=styles, fillrule=fillrule)

        # add path decorations and modify path accordingly
        for adeco in attr.getattrs(attrs, [deco.deco]):
            adeco.decorate(dp, self.texrunner)

        self.insert(dp)
コード例 #4
0
ファイル: deco.py プロジェクト: asuar078/python_workspace
 def __init__(self, dist, angle, strokestyles=[], cross=0):
     attr.clearclass.__init__(self, _filled)
     attr.exclusiveattr.__init__(self, linehatched)
     self.dist = dist
     self.angle = angle
     self.strokestyles = attr.mergeattrs([style.linewidth.THIN] + strokestyles)
     attr.checkattrs(self.strokestyles, [style.strokestyle])
     self.cross = cross
コード例 #5
0
ファイル: deco.py プロジェクト: dcf21/pyxplot7
 def __init__(self, attrs=[], pos=1, reversed=0, size=_base, angle=45, constriction=0.8):
     self.attrs = attr.mergeattrs([style.linestyle.solid, filled] + attrs)
     attr.checkattrs(self.attrs, [deco, style.fillstyle, style.strokestyle])
     self.pos = pos
     self.reversed = reversed
     self.size = size
     self.angle = angle
     self.constriction = constriction
コード例 #6
0
 def __init__(self, dist, angle, strokestyles=[], cross=0):
     attr.clearclass.__init__(self, _filled)
     attr.exclusiveattr.__init__(self, linehatched)
     self.dist = dist
     self.angle = angle
     self.strokestyles = attr.mergeattrs([style.linewidth.THIN] +
                                         strokestyles)
     attr.checkattrs(self.strokestyles, [style.strokestyle])
     self.cross = cross
コード例 #7
0
 def __init__(self,
              attrs=[],
              pos=1,
              reversed=0,
              size=_base,
              angle=45,
              constriction=0.8):
     self.attrs = attr.mergeattrs([style.linestyle.solid, filled] + attrs)
     attr.checkattrs(self.attrs, [deco, style.fillstyle, style.strokestyle])
     self.pos = pos
     self.reversed = reversed
     self.size = size
     self.angle = angle
     self.constriction = constriction
コード例 #8
0
ファイル: canvas.py プロジェクト: epavlick/esl-sent-anal
    def __init__(self, attrs=None, texrunner=None):

        """construct a canvas

        The canvas can be modfied by supplying a list of attrs, which have
        to be instances of one of the following classes:
         - trafo.trafo (leading to a global transformation of the canvas)
         - canvas.clip (clips the canvas)
         - style.strokestyle, style.fillstyle (sets some global attributes of the canvas)

        Note that, while the first two properties are fixed for the
        whole canvas, the last one can be changed via canvas.set().

        The texrunner instance used for the text method can be specified
        using the texrunner argument. It defaults to text.defaulttexrunner

        """

        self.items = []
        self.trafo = trafo.trafo()
        self.clipbbox = None
        if attrs is None:
            attrs = []
        if texrunner is not None:
            self.texrunner = texrunner
        else:
            # prevent cyclic imports
            import text

            self.texrunner = text.defaulttexrunner

        attr.checkattrs(attrs, [trafo.trafo_pt, clip, style.strokestyle, style.fillstyle])
        # We have to reverse the trafos such that the PostScript concat operators
        # are in the right order. Correspondingly, we below multiply the current self.trafo
        # from the right.
        # Note that while for the stroke and fill styles the order doesn't matter at all,
        # this is not true for the clip operation.
        for aattr in attrs[::-1]:
            if isinstance(aattr, trafo.trafo_pt):
                self.trafo = self.trafo * aattr
            elif isinstance(aattr, clip):
                if self.clipbbox is None:
                    self.clipbbox = aattr.clipbbox().transformed(self.trafo)
                else:
                    self.clippbox *= aattr.clipbbox().transformed(self.trafo)
            self.items.append(aattr)
コード例 #9
0
    def __init__(self, attrs=None, texrunner=None):
        """construct a canvas

        The canvas can be modfied by supplying a list of attrs, which have
        to be instances of one of the following classes:
         - trafo.trafo (leading to a global transformation of the canvas)
         - canvas.clip (clips the canvas)
         - style.strokestyle, style.fillstyle (sets some global attributes of the canvas)

        Note that, while the first two properties are fixed for the
        whole canvas, the last one can be changed via canvas.set().

        The texrunner instance used for the text method can be specified
        using the texrunner argument. It defaults to text.defaulttexrunner

        """

        self.items = []
        self.trafo = trafo.trafo()
        self.clipbbox = None
        self.layers = {}
        if attrs is None:
            attrs = []
        if texrunner is not None:
            self.texrunner = texrunner
        else:
            # prevent cyclic imports
            import text
            self.texrunner = text.defaulttexrunner

        attr.checkattrs(
            attrs, [trafo.trafo_pt, clip, style.strokestyle, style.fillstyle])
        # We have to reverse the trafos such that the PostScript concat operators
        # are in the right order. Correspondingly, we below multiply the current self.trafo
        # from the right.
        # Note that while for the stroke and fill styles the order doesn't matter at all,
        # this is not true for the clip operation.
        for aattr in attrs[::-1]:
            if isinstance(aattr, trafo.trafo_pt):
                self.trafo = self.trafo * aattr
            elif isinstance(aattr, clip):
                if self.clipbbox is None:
                    self.clipbbox = aattr.clipbbox().transformed(self.trafo)
                else:
                    self.clippbox *= aattr.clipbbox().transformed(self.trafo)
            self.items.append(aattr)
コード例 #10
0
ファイル: deco.py プロジェクト: asuar078/python_workspace
    def __init__(self, attrs=[], pos=1, reversed=0, size=_base, angle=45, constriction=0.8):
        self.attrs = attr.mergeattrs([style.linestyle.solid, filled] + attrs)
        attr.checkattrs(self.attrs, [deco, style.fillstyle, style.strokestyle])
        self.pos = pos
        self.reversed = reversed
        self.size = size
        self.angle = angle
        self.constriction = constriction

        # calculate absolute arc length of constricition
        # Note that we have to correct this length because the arrowtemplates are rotated
        # by self.angle/2 to the left and right. Hence, if we want no constriction, i.e., for
        # self.constriction = 1, we actually have a length which is approximately shorter
        # by the given geometrical factor.
        if self.constriction is not None:
            self.constrictionlen = self.size * self.constriction * math.cos(math.radians(self.angle/2.0))
        else:
            # if we do not want a constriction, i.e. constriction is None, we still
            # need constrictionlen for cutting the path
            self.constrictionlen = self.size * 1 * math.cos(math.radians(self.angle/2.0))
コード例 #11
0
ファイル: deco.py プロジェクト: asuar078/python_workspace
 def __init__(self, styles=[]):
     attr.exclusiveattr.__init__(self, _filled)
     self.styles = attr.mergeattrs(styles)
     attr.checkattrs(self.styles, [style.fillstyle])
コード例 #12
0
 def __init__(self, styles=[]):
     attr.exclusiveattr.__init__(self, _filled)
     self.styles = attr.mergeattrs(styles)
     attr.checkattrs(self.styles, [style.fillstyle])