当前位置: 首页>>代码示例>>Python>>正文


Python Line.draw方法代码示例

本文整理汇总了Python中line.Line.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Line.draw方法的具体用法?Python Line.draw怎么用?Python Line.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在line.Line的用法示例。


在下文中一共展示了Line.draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import draw [as 别名]
def main():
    win_w, win_h = (640, 480)
    win_bgc = Colors.black
    # win

    win = Win(win_w, win_h)
    win.draw.draw_clear(win_bgc)

    random.seed()

    l = Line(win)
    l.set_pos(win_w / 2.0, win_h / 2.0)

    while win.tick():
        l.set_color(Colors.black + random.randrange(0x1000000))
        for i in range(20):
            l.rotate(math.pi * (-1.0 + (random.random() * 2.0)) / 6.0)
            l.set_rad(1 + random.randrange(4))
            l.calc_end()
            l.draw()
            l.move_seg()
        win.render()

    win.quit()
    return 0
开发者ID:eyedeeemm,项目名称:nitrogen,代码行数:27,代码来源:squig.py

示例2: draw

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import draw [as 别名]
    def draw(self, *args, **kwargs):
        """
        Draw both the Line and the Axis' label.

        Does not draw the Ticks. See Axis.drawTicks() for that.
        """
        Line.draw(self, *args, **kwargs)
        self._label.draw(*args, **kwargs)
开发者ID:bbreslauer,项目名称:Pygraphene,代码行数:10,代码来源:axis.py

示例3: Tick

# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import draw [as 别名]
class Tick(Parent):
    """
    An individual tick mark, which contains both a Line and a Text label. It
    is attached to a specific axis.
    """

    def __init__(self, canvas, axis, dataLoc, length, direction, tickMarkProps={}, labelProps={}):
        """
        **Constructor**

        axis
            The Axis instance this tick is attached to.

        dataLoc
            The data coordinate that this tick will be located at.

        length
            The length of the tick mark.

        direction
            Whether the tick should be drawn to the inside or outside of the axis.
            Valid values are 'in', 'out', and 'both'. Defaults to 'in'.

        tickMarkProps
            Keyword arguments for the tick mark Line object.

        labelProps
            Keyword arguments for the label Text object.
        """

        Parent.__init__(self)

        self._tickMark = Line(canvas, **tickMarkProps)
        self._label = Text(canvas, **labelProps)
        self._axis = axis

        self.addChild(self._tickMark)
        self.addChild(self._label)
        
        # Location where the tick should be placed, in data coords
        self._dataLocation = dataLoc

        self._length = 5
        self.setLength(length)

        self._direction = 'in'
        self.setDirection(direction)

    def setLabel(self, text=None, **kwprops):
        """
        Update the label Text object with the passed text and kwprops.

        If text is not a string, then the label's text will not be changed.

        If both text and kwprops['text'] are defined, the text argument takes precedence.
        """

        if isinstance(text, str):
            kwprops['text'] = text
        self._label.setProps(**kwprops)

    def setLength(self, length):
        """
        Update the length of the tick mark. The length must be an int.
        """
        if isinstance(length, int):
            self._length = length

    def setDirection(self, direction):
        """
        Update the direction of the tick mark. The direction must be either 'in'
        or 'out', and refers to whether the tick mark should be inside or outside
        the plot. The label will always be outside.
        """
        if direction in ('in', 'out', 'both'):
            self._direction = direction

    def setTickMarkProps(self, **kwprops):
        """Update the tick mark Line object with the passed kwprops."""
        self._tickMark.setProps(**kwprops)

    def setTickPosition(self):
        """
        Set the position, in plot coordinates, of both the tick mark Line object
        and the label Text object.
        """

        # Determine various points in plot coordinates
        plotLocation = self._axis.mapDataToPlot(self._dataLocation)
        labelPosition = self._axis._plotAnchor
        startPosition = self._axis._plotAnchor
        endPosition = startPosition

        if self._axis.inside() == 'up' and self._direction == 'in':
            endPosition = startPosition + self._length
        elif self._axis.inside() == 'up' and self._direction == 'out':
            endPosition = startPosition - self._length
        elif self._axis.inside() == 'up' and self._direction == 'both':
            endPosition = startPosition - self._length
            startPosition += self._length
#.........这里部分代码省略.........
开发者ID:bbreslauer,项目名称:Pygraphene,代码行数:103,代码来源:axis.py


注:本文中的line.Line.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。