python类setposition()的实例源码

plot.py 文件源码 项目:jvcprojectortools 作者: arvehj 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def draw_line(self, pos, horizontal=False, label=None,
                  color='gray90', label_color='gray35', **_):
        """Draw one horizontal or vertical line with optional color and label"""
        if pos is None:
            return
        if pos < self.zoom_area[0 + horizontal] or pos > self.zoom_area[2 + horizontal]:
            return
        turtle.penup()
        xscale = turtle.getscreen().xscale
        yscale = turtle.getscreen().yscale
        if label:
            font_family, font_size = self.font
            turtle.color(label_color)
            turtle.setposition(*self.label_pos(pos=pos, label=label, horizontal=horizontal))
            turtle.write(label, align='right' if horizontal else'center',
                         font=(font_family, font_size))
            turtle.setposition(-4 / xscale if horizontal else pos,
                               pos if horizontal else -4 / yscale)
            turtle.pendown()
        turtle.setposition(1 / xscale if horizontal else pos,
                           pos if horizontal else 1 / yscale)
        turtle.color(color)
        turtle.pendown()
        turtle.setposition(self.plot_area[2] if horizontal else pos,
                           pos if horizontal else self.plot_area[3])
        turtle.penup()
plot.py 文件源码 项目:jvcprojectortools 作者: arvehj 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def plot_table(self, *gamma, colors=['red', 'green', 'blue'], draw_speed=16, scale_x=1):
        """Plot gamma table"""
        if len(gamma) == 1 and len(gamma[0]) == 3:
            gamma = gamma[0]
        if all(x == gamma[0] for x in gamma):
            gamma = gamma[:1]

        turtle.penup()
        turtle.tracer(0, 16)
        turtle.speed(0)
        turtle.color('black')
        for color, points_y in enumerate(gamma):
            if len(gamma) == len(colors):
                turtle.color(colors[color])
            elif len(colors) == 1:
                turtle.color(colors[0])
            for x, y in enumerate(points_y):
                trace = x and x % draw_speed == 0
                if trace:
                    turtle.tracer(1)
                turtle.setposition(x * scale_x, y)
                if trace:
                    turtle.tracer(0)
                if x == 0:
                    turtle.showturtle()
                    turtle.pendown()

            turtle.penup()
            turtle.hideturtle()
            turtle.update()
scheme_primitives.py 文件源码 项目:Scheme 作者: StephenK1998 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def tscheme_setposition(x, y):
    """Set turtle's position to (X,Y), heading unchanged."""
    _check_nums(x, y)
    _tscheme_prep()
    turtle.setposition(x, y)
    return okay
scheme_primitives.py 文件源码 项目:Charon 作者: forrestchang 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def tscheme_setposition(x, y):
    """Set turtle's position to (X,Y), heading unchanged."""
    _check_nums(x, y)
    _tscheme_prep()
    turtle.setposition(x, y)
    return okay
scheme_primitives.py 文件源码 项目:SchemeInterpreter 作者: GrantHiggins16 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def tscheme_setposition(x, y):
    """Set turtle's position to (X,Y), heading unchanged."""
    _check_nums(x, y)
    _tscheme_prep()
    turtle.setposition(x, y)
    return okay


问题


面经


文章

微信
公众号

扫码关注公众号