本文整理汇总了Python中turtle.setup函数的典型用法代码示例。如果您正苦于以下问题:Python setup函数的具体用法?Python setup怎么用?Python setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:xzlxiao,项目名称:Test,代码行数:7,代码来源:蟒蛇绘制.py
示例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()
开发者ID:mtahmed,项目名称:lsystems,代码行数:30,代码来源:dragon.py
示例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)
开发者ID:jonobrien,项目名称:School_Backups,代码行数:29,代码来源:spell_out.py
示例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)
开发者ID:lovexleif,项目名称:python,代码行数:7,代码来源:snake.py
示例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()
开发者ID:godLYC,项目名称:hello-world,代码行数:25,代码来源:turtle.py
示例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)
开发者ID:slott56,项目名称:HamCalc-2.1,代码行数:26,代码来源:gwgraphics.py
示例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)
开发者ID:jorgenkg,项目名称:IT3105,代码行数:34,代码来源:visuals.py
示例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()
开发者ID:GBedenko,项目名称:introduction-to-computing-assignment,代码行数:31,代码来源:Game.py
示例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!")
开发者ID:hifzasakhi,项目名称:Polygonville,代码行数:29,代码来源:polygonville.py
示例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)
开发者ID:DougMHu,项目名称:roomba-obstacle-mapping,代码行数:30,代码来源:turtle_roomba.py
示例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 )
开发者ID:Andor-Z,项目名称:My-Learning-Note,代码行数:7,代码来源:week2.py
示例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 )
开发者ID:TianbinJiang,项目名称:LeetCode,代码行数:31,代码来源:maze.py
示例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()
开发者ID:alexandreou,项目名称:PyCalc,代码行数:34,代码来源:Add_PyCalc_32_fx.py
示例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"
开发者ID:jzmnd,项目名称:nw-network-model,代码行数:27,代码来源:nwnet.py
示例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()
开发者ID:silentShadow,项目名称:CSC101,代码行数:34,代码来源:compute_angles_redux.py
示例16: viewer
def viewer(dna):
'''Display ORFs and GC content for dna.'''
dna = dna.upper() # make everything upper case, just in case
t = turtle.Turtle()
turtle.setup(1440, 240) # make a long, thin window
turtle.screensize(len(dna) * 6, 200) # make the canvas big enough to hold the sequence
# scale coordinate system so one character fits at each point
setworldcoordinates(turtle.getscreen(), 0, 0, len(dna), 6)
turtle.hideturtle()
t.speed(0)
t.tracer(100)
t.hideturtle()
# Draw the sequence across the bottom of the window.
t.up()
for i in range(len(dna)):
t.goto(i, 0)
t.write(dna[i],font=("Helvetica",8,"normal"))
# Draw bars for ORFs in forward reading frames 0, 1, 2.
# Draw the bar for reading frame i at y = i + 1.
t.width(5) # width of the pen for each bar
for i in range(3):
orf(dna, i, t)
t.width(1) # reset the pen width
gcFreq(dna, 20, t) # plot GC content over windows of size 20
turtle.exitonclick()
开发者ID:BazzalSeed,项目名称:Python_Practices,代码行数:31,代码来源:temp.py
示例17: drawBoard
def drawBoard(b):
#set up window
t.setup(600,600)
t.bgcolor("dark green")
#turtle settings
t.hideturtle()
t.speed(0)
num=len(b)
side=600/num
xcod=-300
ycod=-300
for x in b:
for y in x:
if(y> 0):
drawsquare(xcod,ycod,side,'black')
if(y< 0):
drawsquare(xcod,ycod,side,'white')
if(y==0):
drawsquare(xcod,ycod,side,'dark green')
xcod=xcod+side
xcod=-300
ycod=ycod+side
开发者ID:gK996,项目名称:Othello,代码行数:25,代码来源:project2.py
示例18: main
def main():
bob = turtle.Turtle()
turtle.title('Sun Figure')
turtle.setup(800, 800, 0, 0)
bob.speed(0)
bobMakesASun(bob, 1, 'purple')
turtle.done()
开发者ID:enterth3r4in,项目名称:Shapes-,代码行数:7,代码来源:Shapes.py
示例19: main
def main():
turtle.setup(800, 350, 200, 200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
drawDate(datetime.datetime.now().strftime('%Y%m%d'))
turtle.hideturtle()
开发者ID:BrandonSherlocking,项目名称:python_document,代码行数:7,代码来源:数码管.py
示例20: __init__
def __init__(self):
# Janela sobre
self.janSobre = None
# Cor de fundo
self.corFundo = "gray"
turtle.screensize(1000, 700, self.corFundo)
turtle.setup(width=1000, height=700)
turtle.title("cidadeBela - Janela de desenho")
turtle.speed(0)
turtle.tracer(4)
# Definindo variáveis globais
self._tamPadrao = ""
# Listas de prédios
self.predios = ['Casa', 'Hotel']
self.prediosProc = [ 'hotel', 'hotelInv', 'casa', 'casaInv' ]
# Sorteando elementos
self.sorteioPredios = [["casa", 1], ["hotel", 1]]
self.sorteioPrediosInv = [["casaInv", 1], ["hotelInv", 1]]
# Cores dos prédios
self.coresHotel = ["076080190", "255255255", "167064057", "153204255", "000090245",
"201232098", "255058123", "010056150", "130255255", "255255000",
"255000000", "255127042", "000255000", "255170255", "000255170",
"212000255", "170255127", "127212255", "255127127", "255212085",
"212212255", "255255127", "222202144" ]
self.coresCasa = ['209187103', '115155225', '130047006', '255137111', '203229057',
'017130100', '025195159', '204057065', '194082255', '092221159',
'167045055', '238243030', '069241248', '000156228', '159094040',
'048033253', '040209239', '138164253', '190042177', '000122159',
'255255255', '253208201', '245228133']
self.coresLoja = ['255255255', '253208201', '245228133' ]
# Janelas dos prédios
self.janelasHotel = janelas.janelasHotel
self.janelasCasa = janelas.janelasCasa
self.janelasLoja = janelas.janelasLoja
self.janelasTodas = janelas.janelasTodas
# Tetos dos prédios
self.tetosHotel = tetos.tetosHotel
self.tetosCasa = tetos.tetosCasa
self.tetosLoja = tetos.tetosLoja
self.tetosTodas = tetos.tetosTodas
# Portas dos prédios
self.portasHotel = portas.portasHotel
self.portasCasa = portas.portasCasa
self.portasLoja = portas.portasLoja
self.portasTodas = portas.portasTodas
开发者ID:SrMouraSilva,项目名称:Academic-Projects,代码行数:60,代码来源:cb.py
注:本文中的turtle.setup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论