當前位置: 首頁>>代碼示例>>Python>>正文


Python turtle.tracer方法代碼示例

本文整理匯總了Python中turtle.tracer方法的典型用法代碼示例。如果您正苦於以下問題:Python turtle.tracer方法的具體用法?Python turtle.tracer怎麽用?Python turtle.tracer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在turtle的用法示例。


在下文中一共展示了turtle.tracer方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup_screen

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200):
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(screen_size_x, screen_size_y)
    turtle.hideturtle()
    turtle.penup()
    turtle.backward(240)
    turtle.tracer(tracer_size)
    turtle.bgcolor(background)  # Set the background colour of the screen 
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:11,代碼來源:mandelbrot.py

示例2: __init__

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def __init__(
                self,
                screen_width = 800,
                screen_height = 600,
                background_color = "black",
                title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
                splash_time = 3):

        # Setup using Turtle module methods
        turtle.setup(width=screen_width, height=screen_height)
        turtle.bgcolor(background_color)
        turtle.title(title)
        turtle.tracer(0) # Stop automatic screen refresh
        turtle.listen() # Listen for keyboard input
        turtle.hideturtle() # Hides default turtle
        turtle.penup() # Puts pen up for defaut turtle
        turtle.setundobuffer(0) # Do not keep turtle history in memory
        turtle.onscreenclick(self.click)

        # Game Attributes
        self.SCREEN_WIDTH = screen_width
        self.SCREEN_HEIGHT = screen_height
        self.DATAFILE = "game.dat"
        self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file

        self.fps = 30.0 # Lower this on slower computers or with large number of sprites
        self.title = title
        self.gravity = 0
        self.state = "showsplash"
        self.splash_time = splash_time

        self.time = time.time()

        # Clear the terminal and print the game title
        self.clear_terminal_screen()
        print (self.title)

        # Show splash
        self.show_splash(self.splash_time)

    # Pop ups 
開發者ID:wynand1004,項目名稱:SPGL,代碼行數:43,代碼來源:spgl.py

示例3: leftCheek

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def leftCheek(self, x, y):
        turtle.tracer(False)
        t = self.t
        self.noTrace_goto(x, y)
        t.seth(300)
        t.fillcolor('#DD4D28')
        t.begin_fill()
        a = 2.3
        for i in range(120):
            if 0 <= i < 30 or 60 <= i < 90:
                a -= 0.05
                t.lt(3)
                t.fd(a)
            else:
                a += 0.05
                t.lt(3)
                t.fd(a)
        t.end_fill()
        turtle.tracer(True) 
開發者ID:PerpetualSmile,項目名稱:Python-Painting-Doraemon,代碼行數:21,代碼來源:Pikachu.py

示例4: rightCheek

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def rightCheek(self, x, y):
        t = self.t
        turtle.tracer(False)
        self.noTrace_goto(x, y)
        t.seth(60)
        t.fillcolor('#DD4D28')
        t.begin_fill()
        a = 2.3
        for i in range(120):
            if 0 <= i < 30 or 60 <= i < 90:
                a -= 0.05
                t.lt(3)
                t.fd(a)
            else:
                a += 0.05
                t.lt(3)
                t.fd(a)
        t.end_fill()
        turtle.tracer(True) 
開發者ID:PerpetualSmile,項目名稱:Python-Painting-Doraemon,代碼行數:21,代碼來源:Pikachu.py

示例5: startTick

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def startTick(second_hand, minute_hand, hour_hand, printer):
	today = datetime.datetime.today()
	second = today.second + today.microsecond * 1e-6
	minute = today.minute + second / 60.
	hour = (today.hour + minute / 60) % 12
	# 設置朝向
	second_hand.setheading(6 * second)
	minute_hand.setheading(6 * minute)
	hour_hand.setheading(12 * hour)
	turtle.tracer(False)
	printer.forward(65)
	printer.write(getWeekday(today), align='center', font=("Courier", 14, "bold"))
	printer.forward(120)
	printer.write('12', align='center', font=("Courier", 14, "bold"))
	printer.back(250)
	printer.write(getDate(today), align='center', font=("Courier", 14, "bold"))
	printer.back(145)
	printer.write('6', align='center', font=("Courier", 14, "bold"))
	printer.home()
	printer.right(92.5)
	printer.forward(200)
	printer.write('3', align='center', font=("Courier", 14, "bold"))
	printer.left(2.5)
	printer.back(400)
	printer.write('9', align='center', font=("Courier", 14, "bold"))
	printer.home()
	turtle.tracer(True)
	# 100ms調用一次
	turtle.ontimer(lambda: startTick(second_hand, minute_hand, hour_hand, printer), 100) 
開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:31,代碼來源:clock.py

示例6: start

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def start():
	# 不顯示繪製時鍾的過程
	turtle.tracer(False)
	turtle.mode('logo')
	createHand('second_hand', 150)
	createHand('minute_hand', 125)
	createHand('hour_hand', 85)
	# 秒, 分, 時
	second_hand = turtle.Turtle()
	second_hand.shape('second_hand')
	minute_hand = turtle.Turtle()
	minute_hand.shape('minute_hand')
	hour_hand = turtle.Turtle()
	hour_hand.shape('hour_hand')
	for hand in [second_hand, minute_hand, hour_hand]:
		hand.shapesize(1, 1, 3)
		hand.speed(0)
	# 用於打印日期等文字
	printer = turtle.Turtle()
	printer.hideturtle()
	printer.penup()
	createClock(160)
	# 開始顯示軌跡
	turtle.tracer(True)
	startTick(second_hand, minute_hand, hour_hand, printer)
	turtle.mainloop() 
開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:28,代碼來源:clock.py

示例7: setup_screen

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=800):
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(screen_size_x, screen_size_y)
    turtle.hideturtle()
    turtle.penup()
    turtle.backward(240)
    # Batch drawing to the screen for faster rendering
    turtle.tracer(tracer_size)
    turtle.bgcolor(background)  # Set the background colour of the screen 
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:12,代碼來源:snowflake_koch.py

示例8: setup_screen

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def setup_screen(title, background = 'white'):
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(640, 600)
    turtle.hideturtle()
    turtle.penup()
    turtle.tracer(200)
    turtle.bgcolor(background)  # Set the background colour of the screen 
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:10,代碼來源:snowflake.py

示例9: setup_screen

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200):
    """ Sets up Turtle screen with useful defaults """
    print('Set up Screen')
    turtle.title(title)
    turtle.setup(screen_size_x, screen_size_y)
    turtle.hideturtle()
    turtle.penup()
    turtle.backward(240)
    turtle.tracer(tracer_size)
    turtle.bgcolor(background)  # Set the background colour of the screen 
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:12,代碼來源:fractal_trees.py

示例10: __init__

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def __init__(
                self,
                screen_width = 800,
                screen_height = 600,
                background_color = "black",
                title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
                splash_time = 3):

        # Setup using Turtle module methods
        turtle.setup(width=screen_width, height=screen_height)
        turtle.bgcolor(background_color)
        turtle.title(title)
        turtle.tracer(0) # Stop automatic screen refresh
        turtle.listen() # Listen for keyboard input
        turtle.hideturtle() # Hides default turtle
        turtle.penup() # Puts pen up for defaut turtle
        turtle.setundobuffer(0) # Do not keep turtle history in memory
        turtle.onscreenclick(self.click)

        # Game Attributes
        self.FPS = 30.0 # Lower this on slower computers or with large number of sprites
        self.SCREEN_WIDTH = screen_width
        self.SCREEN_HEIGHT = screen_height
        self.DATAFILE = "game.dat"
        self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file

        self.title = title
        self.gravity = 0
        self.state = "showsplash"
        self.splash_time = splash_time

        self.time = time.time()

        # Clear the terminal and print the game title
        self.clear_terminal_screen()
        print (self.title)

        # Show splash
        self.show_splash(self.splash_time)

    # Pop ups 
開發者ID:wynand1004,項目名稱:SPGL,代碼行數:43,代碼來源:spgl.py

示例11: setup_window

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def setup_window():
    # Set up the window
    turtle.title('Circles in My Mind')
    turtle.setup(WIDTH, HEIGHT, 0, 0)
    turtle.colormode(255)  # Indicates RGB numbers will be in the range 0 to 255
    turtle.hideturtle()
    # Batch drawing to the screen for faster rendering
    turtle.tracer(2000)

    # Speed up drawing process
    turtle.speed(10)
    turtle.penup() 
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:14,代碼來源:circles-picture.py

示例12: show_maze

# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import tracer [as 別名]
def show_maze(self):

        turtle.setworldcoordinates(0, 0, self.width * 1.005, self.height * 1.005)

        wally = turtle.Turtle()
        wally.speed(0)
        wally.width(1.5)
        wally.hideturtle()
        turtle.tracer(0, 0)

        for i in range(self.num_rows):
            for j in range(self.num_cols):
                permissibilities = self.permissibilities(cell = (i,j))
                turtle.up()
                wally.setposition((j * self.grid_width, i * self.grid_height))
                # Set turtle heading orientation
                # 0 - east, 90 - north, 180 - west, 270 - south
                wally.setheading(0)
                if not permissibilities[0]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_width)
                wally.setheading(90)
                wally.up()
                if not permissibilities[1]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_height)
                wally.setheading(180)
                wally.up()
                if not permissibilities[2]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_width)
                wally.setheading(270)
                wally.up()
                if not permissibilities[3]:
                    wally.down()
                else:
                    wally.up()
                wally.forward(self.grid_height)
                wally.up()

        turtle.update() 
開發者ID:leimao,項目名稱:Particle_Filter,代碼行數:49,代碼來源:maze.py


注:本文中的turtle.tracer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。