本文整理汇总了Python中turtle.setup函数的典型用法代码示例。如果您正苦于以下问题:Python setup函数的具体用法?Python setup怎么用?Python setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
turtle.setup(1300, 800, 0, 0) # 启动图形窗口
pythonsize = 10
turtle.pensize(pythonsize)
turtle.pencolor("blue")
turtle.seth(-40) # 启动时运动的方向(角度)
drawSnake(40, 80, 5, pythonsize/2)
示例2: draw
def draw(self):
super(DragonLSystem, self).draw()
turtle.setup(800,600)
wn = turtle.Screen()
wn.bgcolor('lightblue')
wn.title("Wingled Dragon")
self.turtle = turtle.Turtle()
self.turtle.shape('blank')
turtle.tracer(int(sys.argv[2]),25)
t = self.turtle
t.reset()
t.penup()
t.setpos(-200,0)
t.pendown()
i = 200.0
for c in self.state:
if c == "F":
t.forward(math.ceil(i))
elif c == "+":
t.right(90)
elif c == "-":
t.left(90)
elif c == "C":
i = i/math.sqrt(2)
t.left(45)
wn.exitonclick()
示例3: initBannerCanvas
def initBannerCanvas( numChars, numLines ):
"""
Set up the drawing canvas to draw a banner numChars wide and numLines high.
The coordinate system used assumes all characters are 20x20 and there
are 10-point spaces between them.
Postcondition: The turtle's starting position is at the bottom left
corner of where the first character should be displayed.
"""
# This setup function uses pixels for dimensions.
# It creates the visible size of the canvas.
canvas_height = 80 * numLines
canvas_width = 80 * numChars
turtle.setup( canvas_width, canvas_height )
# This setup function establishes the coordinate system the
# program perceives. It is set to match the planned number
# of characters.
height = 30
width = 30 * numChars
margin = 5 # Add a bit to remove the problem with window decorations.
turtle.setworldcoordinates(
-margin+1, -margin+1, width + margin, numLines*height + margin )
turtle.reset()
turtle.up()
turtle.setheading( 90 )
turtle.forward( ( numLines - 1 ) * 30 )
turtle.right( 90 )
turtle.pensize( 2 * scale)
示例4: main
def main():
turtle.setup(1300,800,0,0)
pythonsize=1
turtle.pensize(pythonsize)
turtle.pencolor("black")
turtle.seth(-40)
drawSnack(40,80,5,pythonsize/2)
示例5: main
def main():
turtle.title('数据驱动的动态路径绘制')
turtle.setup(800,600,0,0)
#设置画笔
pen = turtle.Turtle()
pen.color("red")
pen.width(5)
pen.shape("turtle")
pen.speed(5)
#读取文件
result = []
file = open("C:\Users\30908\Desktop\wode.txt","r")
for line in file:
result.append(list(map(float,line.split(","))))
print result
#动态绘制
for i in range(len(result)):
pen.color((result[i][3],result[i][4],result[i][5]))
pen.fd(result[i][0])
if result[i][1]:
pen.rt(result[i][2])
else:
pen.lt(result[i][2])
pen.goto(0,0)
file.close()
示例6: SCREEN
def SCREEN( self, mode ):
"""
SCREEN 0 ● Text mode only
SCREEN 1 ● 320 × 200 pixel medium-resolution graphics ● 80 x 25 text
SCREEN 2 ● 640 × 200 pixel high-resolution graphics ● 40 × 25 text
SCREEN 7 ● 320 × 200 pixel medium-resolution graphics ● 40 × 25 text
SCREEN 8 ● 640 × 200 pixel high-resolution graphics ● 80 × 25 text
SCREEN 9 ● 640 × 350 pixel enhanced-resolution graphics ● 80 × 25 text
SCREEN 10 ● 640 × 350 enhanced-resolution graphics ● 80 × 25 text
"""
if mode == 8:
# Officially 640x200 with rectangular pixels, appears as 640x480.
turtle.setup( width=640, height=480 )
turtle.setworldcoordinates(0,0,640,480)
self.aspect_v = (200/640)*(4/3)
elif mode == 9:
# Official 640x350 with rectangular pixels, appears 640x480.
turtle.setup( width=640, height=480 )
turtle.setworldcoordinates(0,0,640,480)
self.aspect_v = (350/640)*(4/3)
示例7: initialize_plot
def initialize_plot(self, positions):
self.positions = positions
self.minX = minX = min(x for x,y in positions.values())
maxX = max(x for x,y in positions.values())
minY = min(y for x,y in positions.values())
self.maxY = maxY = max(y for x,y in positions.values())
ts = turtle.getscreen()
if ts.window_width > ts.window_height:
max_size = ts.window_height()
else:
max_size = ts.window_width()
self.width, self.height = max_size, max_size
turtle.setworldcoordinates(minX-5,minY-5,maxX+5,maxY+5)
turtle.setup(width=self.width, height=self.height)
turtle.speed("fastest") # important! turtle is intolerably slow otherwise
turtle.tracer(False) # This too: rendering the 'turtle' wastes time
turtle.hideturtle()
turtle.penup()
self.colors = ["#d9684c","#3d658e","#b5c810","#ffb160","#bd42b3","#0eab6c","#1228da","#60f2b7" ]
for color in self.colors:
s = turtle.Shape("compound")
poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
s.addcomponent(poly1, color, "#000000")
turtle.register_shape(color, s)
s = turtle.Shape("compound")
poly1 = ((0,0),(self.cell_size,0),(self.cell_size,-self.cell_size),(0,-self.cell_size))
s.addcomponent(poly1, "#000000", "#000000")
turtle.register_shape("uncolored", s)
示例8: startGame
def startGame():
'''Draws the grid ready to play the game
Clears the grid to make sure it is empty before starting a new game
Displays the rules/how to play to the user
Asks the user which game mode to play by calling gameModeSelection()'''
turtle.setup(650,600)
turtle.title("Noughts and Crosses by Genaro Bedenko")
drawGrid()
# Reset the gridSquares to be empty
# This is needed for when a game has already been played and the player chose
# to play again, they need to play from a new grid
for i in range(1,10):
gridSquares[i] = 0
displayRules()
playSavedGame = messagebox.askquestion(title="Play Previous Game?", message="Do you want to play a previously saved game?")
if(playSavedGame=="yes"):
try:
loadGame(gridSquares)
# If the user clicks yes to play a saved game but their isn't one saved in the directory. Display a message to tell them
# this and move on to starting a new game
except FileNotFoundError:
messagebox.showinfo(title="No Saved Game Available", message="There isn't a currently saved game available to play")
gameModeSelection()
else:
gameModeSelection()
示例9: main
def main():
# set up the name of the window
turtle.title("Polygonville")
# setup the screen size through (1000, 650)
# setup the initial location through (0,0)
turtle.setup(1000,650,0,0)
print("Welcome to Polygonville!")
totalSides = input("Input number of sides in the polygon: ")
while totalSides != 0:
if totalSides < 3:
print("Sorry, " + str(totalSides) + " is not "
+ "valid, try again or press 0 to exit")
elif totalSides == 3:
totalAngles = 180 * (totalSides - 2)
sideLength = input("Put polygon sidelength: ")
angle = totalAngles/totalSides
func1(totalSides, sideLength, angle, totalAngles)
else:
totalAngles = 180 * (totalSides - 2)
sideLength = input("Put polygon side length: ")
angle = totalAngles/totalSides
func2(totalSides, sideLength, angle, totalAngles)
if totalSides > 3:
print("Polygon Summary: \n" +
"Sides: " + str(totalSides) + "| Anterior Angle: " +
str(angle) + "| Sum of Angles: " + str(totalAngles))
totalSides = input("\nInput number of sides in the polygon: ")
if totalSides == 0:
print("Thank you for using Polygonville!")
示例10: __init__
def __init__(self, length, width, roomba_step, obstacles=None):
'''
###initialization
'''
self.obstacles = obstacles
self.orient = 0
self.length = length #assume length in m
self.width = width #assume width in m
self.roomba_step = roomba_step#assume in m
self.multiply_factor = 50 #screenstep = multiply_factor * length/width
self.step_l = self.length*self.multiply_factor
self.step_w = self.width*self.multiply_factor
self.roomba_l = self.roomba_step*self.multiply_factor
self.t = turtle.Turtle()
self.t.shape("classic")
turtle.setup(self.step_l+100,self.step_w+100)
turtle.screensize(self.step_l+10, self.step_w+10)
#turtle.bgcolor("orange")
self.t.penup()
self.t.bk(self.step_l/2) # backward()
self.t.lt(90) # left()
self.t.fd(self.step_w/2) # forward()
self.t.rt(90) # right()
self.draw_boundary(self.step_l, self.step_w, self.roomba_l, self.t)
###set pen width
self.t.pendown()
self.t.pencolor("green")
self.t.pensize(self.roomba_l-1)
self.t.fd(self.roomba_l)
示例11: main
def main():
turtle.setup(1300, 800, 0, 0)
pythonsize = 30
turtle.pensize(pythonsize)
turtle.pencolor('blue')
turtle.seth(-40)
drawSnake(rad = 40, angle = 80, len = 5, neckrad = pythonsize/2 )
示例12: __init__
def __init__(self, mazeFileName):
rowsInMaze = 0
columnsInMaze = 0
self.mazelist = []
mazeFile = open(mazeFileName, 'r')
for line in mazeFile:
rowList = []
col = 0
for ch in line[:-1]:
rowList.append(ch)
if ch == 'S':
self.startRow = rowsInMaze
self.startCol = col
col = col + 1
rowsInMaze = rowsInMaze + 1
self.mazelist.append(rowList)
columnsInMaze = len(rowList)
self.rowsInMaze = rowsInMaze
self.columnsInMaze = columnsInMaze
self.xTranslate = -columnsInMaze / 2
self.yTranslate = rowsInMaze / 2
self.t = turtle.Turtle()
self.t.shape('turtle')
self.wn = turtle.Screen()
turtle.setup(width = 600, height = 600)
turtle.setworldcoordinates(-(columnsInMaze - 1)/2 - .5,
-(rowsInMaze - 1) / 2 - .5,
(columnsInMaze - 1)/ 2 + .5,
(rowsInMaze - 1) / 2 + .5 )
示例13: dessine
def dessine(liste):
"""
Fonction qui ce charge de dessiner les courbes.
"""
# Si la liste reçu n'est pas vide.
if liste != []:
# Création de la fenètre turtle.
t = turtle.Turtle()
# On cache la tortue.
t.hideturtle()
# On met la vitesse max.
t.speed(0)
# On configure la taille de la fenètre.
turtle.setup(width=650,height=650)
# Création du repère.
repère(t)
# On compte le nombre de tour à faire.
nb_tour = len(liste)
# Boucle qui permet d'afficher les courbes.
for n in range(nb_tour):
e = liste[n]
f = e[0]
c = e[1]
fonction(t,f,c)
# Mainloop pour que la fenètre reste.
turtle.mainloop()
示例14: plot
def plot(self, node1, node2, debug=False):
"""Plots wires and intersection points with python turtle"""
tu.setup(width=800, height=800, startx=0, starty=0)
tu.setworldcoordinates(-self.lav, -self.lav, self.sample_dimension+self.lav, self.sample_dimension+self.lav)
tu.speed(0)
tu.hideturtle()
for i in self.index:
if debug:
time.sleep(2) # Debug only
tu.penup()
tu.goto(self.startcoords[i][0], self.startcoords[i][1])
tu.pendown()
tu.goto(self.endcoords[i][0], self.endcoords[i][1])
tu.penup()
if self.list_of_nodes is None:
intersect = self.intersections(noprint=True)
else:
intersect = self.list_of_nodes
tu.goto(intersect[node1][0], intersect[node1][1])
tu.dot(10, "blue")
tu.goto(intersect[node2][0], intersect[node2][1])
tu.dot(10, "blue")
for i in intersect:
tu.goto(i[0], i[1])
tu.dot(4, "red")
tu.done()
return "Plot complete"
示例15: main
def main():
# to display the degree sign when printing results
deg = u'\N{DEGREE SIGN}'
turtle.setup(500, 500) # make window set size
win = turtle.Screen() # refer to the screen as win
win.title( "Triangles and Angles!") # change the window title
win.bgcolor( "#D3D3D3") # change background color
# get 3 X,Y coords from the user using eval( input())
x1, y1, x2, y2, x3, y3 = eval( input( "Give 3 points: [e.g. 20, 20, 100, 200, 20, 200] "))
# compute the distances of all points
a = distance( x1, y1, x2, y2)
b = distance( x2, y2, x3, y3)
c = distance( x1, y1, x3, y3)
# round off
d1 = round( a * 100) / 100.0
d2 = round( b * 100) / 100.0
d3 = round( c * 100) / 100.0
# make 3 seperate calls to determine_angle to find all angles opposite their sides
angle_x = determine_angle( a,b,c)
angle_y = determine_angle( b,c,a)
angle_z = determine_angle( c,b,a)
print( "The angles of the triangle are:")
print( "\tAngle A: {:.2f}{} \n\tAngle B: {:.2f}{} \n\tAngle C: {:.2f}{}".format( angle_x,deg,angle_y,deg,angle_z,deg),end='\n\n')
# draw the grid for the layout and referencing of plots
draw_grid()
draw_line( x1, y1, x2, y2, x3, y3, angle_x, angle_y, angle_z)
turtle.done()