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


Python Screen.update方法代码示例

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


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

示例1: main

# 需要导入模块: from turtle import Screen [as 别名]
# 或者: from turtle.Screen import update [as 别名]
def main():
    global d, SHS, SF, A
    A = 42 # answer to the ultimate question ... (you know)
    SHS = A / 20.
    SF = 1.0
    DSF = 1.0038582416
    s = Screen()
    s.setup(800, 600)
    s.reset()
    s.tracer(0)
    d = Turtle(visible=False)
    for i in range(6):
        d.fd(500)
        d.bk(500)
        d.left(60)   

    triangles = []
    for c in range(-5,6,2):
        if abs(c) != 1:
            triangles.append(TriTurtle(c, 1, 1))
            triangles.append(TriTurtle(c, -1, 2))
    for c in range(-4,5,2):
        if c != 0:
            triangles.append(TriTurtle(c, 2, 2))
            triangles.append(TriTurtle(c, -2, 1))
        triangles.append(TriTurtle(c, -4, 2))
        triangles.append(TriTurtle(c, 4, 1))
    for c in range(-3,4,2):
        triangles.append(TriTurtle(c, 5, 2))
        triangles.append(TriTurtle(c, -5, 1))
        triangles.append(TriTurtle(c, -7, 2))
        triangles.append(TriTurtle(c, 7, 1))
    for c in range(-2,3,2):
        triangles.append(TriTurtle(c, 8, 2))
        triangles.append(TriTurtle(c, -8, 1))
    for c in (-1, 1):
        triangles.append(TriTurtle(c, 1, 1))
        triangles.append(TriTurtle(c, -1, 2))
    triangles.append(TriTurtle(0, 2, 2))
    triangles.append(TriTurtle(0, -2, 1))
    s.tracer(1)
                         
    for phi in range(1,361):
        SF = SF*DSF
        s.tracer(0)
        for t in triangles:
            t.setturn(phi)
        #s.tracer(1)
        s.update()
    return "DONE!"
开发者ID:emailechiu,项目名称:emailechiu.github.io,代码行数:52,代码来源:tdemo_trigeo.py

示例2: main

# 需要导入模块: from turtle import Screen [as 别名]
# 或者: from turtle.Screen import update [as 别名]
def main():
    ## create compound yellow/blue turtleshape for planets
    global s
    s = Screen()
    s.setup(1120,840)
    s.reset()
    s.tracer(0, 0)
    t = Turtle()
    t.ht()
    t.pu()
    t.fd(6)
    t.lt(90)

    t.begin_poly()
    t.circle(6, 180)
    t.end_poly()
    m1 = t.get_poly()

    t.begin_poly()
    t.circle(6,180)
    t.end_poly()
    m2 = t.get_poly()

    planetshape = Shape("compound")
    planetshape.addcomponent(m1,"orange")
    planetshape.addcomponent(m2,"blue")
    s.register_shape("planet", planetshape)
    #s.tracer(1,0)
    s.update()
    ## setup gravitational system
    gs = GravSys()
    sun = Star(1000000, Vec(-250,0), Vec(0,-0.35), gs, "circle")
    sun.color("yellow")
    sun.pensize(1.8)
    sun.pu()
    earth = Star(5000, Vec(450,0), Vec(0,70), gs, "planet")
    earth.pencolor("green")
    earth.shapesize(0.8)

    rm=12.0583
    vm=(8.0*5000/rm)**.5
    moon = Star(1, Vec(450+rm,0), Vec(0,70+vm), gs, "planet")
    moon.pencolor("blue")
    moon.shapesize(0.5)
    gs.init()
    gs.start()
    return "Done!"
开发者ID:1c71,项目名称:Program-Practice,代码行数:49,代码来源:planet_and_moon_2.py

示例3: MazeGraphics

# 需要导入模块: from turtle import Screen [as 别名]
# 或者: from turtle.Screen import update [as 别名]
class MazeGraphics(object):
    def __init__(self, config):
        self.width = config.getValueAsInt("maze", "maze_size")
        self.height = config.getValueAsInt("maze", "maze_size")
        self.bg_color = config.getValue("maze", "bg_color")
        self.line_color = config.getValue("maze", "line_color")
        self.line_centroid_color = config.getValue("maze", "line_centroid_color")
        self.forward_centroid_color = config.getValue("maze", "forward_centroid_color")
        self.reverse_centroid_color = config.getValue("maze", "reverse_centroid_color")
        self.path_color = config.getValue("maze", "path_color")
        self.screen = Screen()
        self.setupTurtle(self.width, self.height)

    def setupTurtle(self, width, height):
        self.screen.tracer(False)
        self.screen.screensize(width, height)
        # some basic turtle settings
        self.screen.setworldcoordinates(-1, -1, width + 1, height + 1)
        self.screen.title("Random Turtle Maze")
        self.screen.bgcolor(self.bg_color)
        self.screen.delay(None)
        self.designer = Turtle(visible=False)

    def drawGrid(self):
        for i in xrange(0, self.width + 1):
            self.drawXLines(i, self.width, self.line_color)
        for i in xrange(0, self.height + 1):
            self.drawYLines(i, self.width, self.line_color)
        self.screen.update()

    def drawXLines(self, position, width, color):
        self.drawLines(position, 0, width, color, 90)

    def drawYLines(self, position, width, color):
        self.drawLines(0, position, width, color, 0)

    def drawLines(self, xPosition, yPosition, width, color, heading):
        self.designer.up()
        self.designer.setposition(xPosition, yPosition)
        self.designer.color(color)
        self.designer.down()
        self.designer.setheading(heading)
        self.designer.forward(width)
        self.designer.up()

    def drawCentroid(self, cell, color):
        """
        Draw a centroid for animation purposes but then overwrite it.
        """
        self.designer.setposition(cell.centroid)
        self.designer.dot(5, color)
        self.screen.update()
        self.designer.dot(5, self.bg_color)

    def removeWall(self, posx, posy, heading, color):
        """
            We tear down walls to build the maze
        """
        self.designer.up()
        self.designer.setposition(posx, posy)
        self.designer.down()
        self.designer.color(color)
        self.designer.setheading(heading)
        self.designer.forward(1)
        self.designer.up()
        self.screen.update()

    def drawPath(self, cell1, cell2):
        """
            This draws a line for the solution as it's worked out.
        """
        self.designer.setposition(cell1.centroid)
        self.designer.color(self.path_color)
        direction = self.getDirection(cell1, cell2)
        if direction == "N":
            self.designer.setheading(90)
            self.designer.down()
            self.designer.forward(1)
            self.designer.up()
        elif direction == "S":
            self.designer.setheading(270)
            self.designer.down()
            self.designer.forward(1)
            self.designer.up()
        elif direction == "W":
            self.designer.setheading(0)
            self.designer.down()
            self.designer.forward(1)
            self.designer.up()
        elif direction == "E":
            self.designer.setheading(0)
            self.designer.down()
            self.designer.backward(1)
            self.designer.up()
        self.drawCentroid(cell2, self.line_centroid_color)
        self.screen.update()

    def getDirection(self, currCell, nextCell):
        direction = None
        if nextCell.x < currCell.x:
#.........这里部分代码省略.........
开发者ID:skroah,项目名称:pythonmaze,代码行数:103,代码来源:mazegraphics.py


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