• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python turtle.width函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turtle.width函数的典型用法代码示例。如果您正苦于以下问题:Python width函数的具体用法?Python width怎么用?Python width使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: grid

def grid(side):
	turtle.color("blue")
	#horizontal
	for i in range(1, 5):
		move(-side*3, side*3-i*side)
		turtle.fd(6*side)

	#vertical
	turtle.setheading(-90)
	for i in range(1, 6):
		move(-side*3+i*side, side*3)
		turtle.fd(5*side)
	
	#big square
	turtle.color("red")
	turtle.width(2)
	turtle.setheading(0)
	move(-side*3, side*3)
	for i in range(4):
		if (i % 2 == 0):
			cena = side * 6
		else:
			cena = side * 5
		turtle.fd(cena)
		turtle.rt(90)
开发者ID:jpbat,项目名称:freetime,代码行数:25,代码来源:30.py


示例2: grid

def grid(side):

	sqrt = math.sqrt(squares)

	#horizontal
	for i in range(1,squares):
		if i % sqrt == 0:
			turtle.width(2)
			turtle.color("red")
		move(-side*squares/2., side*squares/2.-i*side)
		turtle.fd(side*squares)
		turtle.width(1)
		turtle.color("black")

	#vertical
	turtle.setheading(-90)
	for i in range(1,squares):
		if i % sqrt == 0:
			turtle.width(2)
			turtle.color("red")
		move(-side*squares/2.+i*side, side*squares/2.)
		turtle.fd(side*squares)
		turtle.width(1)
		turtle.color("black")

	#big square
	move(-side*squares/2., side*squares/2.)
	turtle.width(3)
	turtle.setheading(0)
	turtle.color("blue")
	for i in range(4):
		turtle.fd(side*squares)
		turtle.rt(90)
开发者ID:jpbat,项目名称:freetime,代码行数:33,代码来源:sudoku.py


示例3: drawBoard

def drawBoard():
    global b
    #actually draw the board :D
    turtle.ht()
    turtle.width(5)
    turtle.up()
    turtle.goto(-3*b/2.0,b/2.0)
    turtle.down()
    turtle.seth(0)
    turtle.forward(3*b)
    turtle.up()
    turtle.goto(-3*b/2.0,-b/2.0)
    turtle.down()
    turtle.seth(0)
    turtle.forward(3*b)
    turtle.up()
    turtle.goto(-b/2.0,3*b/2.0)
    turtle.down()
    turtle.seth(270)
    turtle.forward(3*b)
    turtle.up()
    turtle.goto(b/2.0,3*b/2.0)
    turtle.down()
    turtle.seth(270)
    turtle.forward(3*b)
开发者ID:mosest,项目名称:11th-Python,代码行数:25,代码来源:24+-+TicTacToe+Ultimate.py


示例4: draw_move

def draw_move(turtle, cell_size, offset, domino, dx, dy, move_num, step_count):
    shade = (move_num-1) * 1.0/step_count
    rgb = (0, 1-shade, shade)
    turtle.forward((domino.head.x-offset[0]) * cell_size)
    turtle.left(90)
    turtle.forward((domino.head.y-offset[1]) * cell_size)
    turtle.right(90)
    turtle.setheading(domino.degrees)
    turtle.forward(cell_size*.5)
    turtle.setheading(math.atan2(dy, dx) * 180/math.pi)
    pen = turtle.pen()
    turtle.pencolor(rgb)
    circle_pos = turtle.pos()
    turtle.width(4)
    turtle.forward(cell_size*0.05)
    turtle.down()
    turtle.forward(cell_size*0.4)
    turtle.up()
    turtle.pen(pen)
    turtle.setpos(circle_pos)
    turtle.forward(8)
    turtle.setheading(270)
    turtle.forward(8)
    turtle.left(90)
    turtle.down()
    turtle.pencolor(rgb)
    turtle.fillcolor('white')
    turtle.begin_fill()
    turtle.circle(8)
    turtle.end_fill()
    turtle.pen(pen)
    turtle.write(move_num, align='center')
    turtle.up()
开发者ID:donkirkby,项目名称:donimoes,代码行数:33,代码来源:diagram.py


示例5: draw_tree

def draw_tree(n, b, l, size):
	if n < 0:						#base-case
		return
	elif n == 0:					#Draw Leaves
		turtle.color("green")							#Color of leaves
		turtle.width(1)
		numberOfLeaves = random.randint(5, 15)			#Random number of leaves ranging from 5 to 15
		angle = int(270 / numberOfLeaves)				#Angle Range between leaves determined by number of leaves
		for i in range(numberOfLeaves):
			if (randomB(l)):
				angle2 = random.randint(0 + (i * angle), 0 + ((i + 1) * angle))	#Angle between different leaves can be different given the Angle Range
				angle2-=135
				turtle.right(angle2)
				turtle.forward(5)
				turtle.back(5)
				turtle.left(angle2)
		return
	else:							#Draw Tree
		turtle.color("brown")						#Color of Tree
		turtle.forward(size)
		b1 = math.floor(5 * b)						#Using Bushiness to calculate number of branches: Max branchess are 5
		angle = int(270 / b1);						#Angle Range between branches determined by Number of Branches
		for i in range(b1):
			if randomB(b1):
				angle2 = random.randint(0 + (i * angle), 0 + ((i + 1) * angle))	#Angle between different branches can be different given the Angle Range
				angle2-=135
				turtle.right(angle2)
				draw_tree(n - 1, b, l, size * random.uniform(0.4, 0.7))			#Recursion step: size of sub-tree is random
				turtle.left(angle2)
		turtle.color("brown")
		turtle.back(size)
	return
开发者ID:wish343,项目名称:Python,代码行数:32,代码来源:enhanced_tree.py


示例6: draw_grid

def draw_grid(ll,ur):
	size = ur - ll
	for gridsize in [1, 2, 5, 10, 20, 50, 100 ,200, 500]:
		lines = (ur-ll)/gridsize
		# print('gridsize', gridsize, '->', int(lines)+1, 'lines')
		if lines <= 11: break
	turtle.color('gray')
	turtle.width(1)
	x = ll
	while x <= ur:
		if int(x/gridsize)*gridsize == x:
			turtle.penup()
			turtle.goto(x, ll-.25*gridsize)
			turtle.write(str(x),align="center",font=("Arial",12,"normal"))
			turtle.goto(x,ll)
			turtle.pendown()
			turtle.goto(x,ur)
			# print(x,ll,'to',x,ur)
		x += 1
	y = ll
	while y <= ur:
		# horizontal grid lines:
		if int(y/gridsize)*gridsize == y:
			turtle.penup()
			turtle.goto(ll-.1*gridsize, y - .06*gridsize)
			turtle.write(str(y),align="right",font=("Arial",12,"normal"))
			turtle.goto(ll,y)
			turtle.pendown()
			turtle.goto(ur,y)
			# print(ll,y,'to',ur,y)
		y += 1
开发者ID:ipmichael,项目名称:cmsc421,代码行数:31,代码来源:tdraw.py


示例7: drawLine

def drawLine(x,y,rotation,width,length):
    turtle.penup()
    turtle.goto(x,y)
    turtle.width(width)
    turtle.setheading(rotation)
    turtle.pendown()
    turtle.forward(length)
    return turtle.position()
开发者ID:hchiam,项目名称:code7,代码行数:8,代码来源:problem3.py


示例8: drawAxe

def drawAxe(padEcart):
	turtle.color(0.7,0.7,0.7)	
	turtle.width(1)
	padAngle = math.pi/5
	for idx in range(0,5):
		turtle.up()
		turtle.goto((math.sin(idx*padAngle)*padEcart*11.0),math.cos(idx*padAngle)*padEcart*11.0)
		turtle.down()
		turtle.goto(-math.sin(idx*padAngle)*padEcart*11.0,-math.cos(idx*padAngle)*padEcart*11.0)
	turtle.down()
开发者ID:Jerome-Celle,项目名称:BricaBrac,代码行数:10,代码来源:pi.py


示例9: draw

 def draw(self,turtle):
     turtle.width(self.width)
     turtle.pencolor(self.color)
     turtle.forward(self.longside)
     turtle.right(90)
     turtle.forward(self.shortside)
     turtle.right(90)
     turtle.forward(self.longside)
     turtle.right(90)
     turtle.forward(self.shortside)
开发者ID:MannyLian,项目名称:Data-Structures-and-Algorithms-with-Python-,代码行数:10,代码来源:1.19Programming+Problem-2.py


示例10: polygon

def polygon(sides, length, colour = "Black", width = 1, speed = 10):

    turtle.pencolor(colour)
    turtle.width(width)
    turtle.speed(speed)
    turtle.pendown()
    for vector in range(sides):
        turtle.forward(length)
        turtle.right(360 / sides)
    turtle.penup()
    turtle.done()
开发者ID:ianpottinger,项目名称:Python3,代码行数:11,代码来源:turtlebot.py


示例11: draw

 def draw(self,turtle):
     turtle.width(self.width)
     turtle.pencolor(self.color)
     turtle.forward(self.length)
     turtle.right(90)
     turtle.forward(self.length)
     turtle.right(90)
     turtle.forward(self.length)
     turtle.right(90)
     turtle.forward(self.length)
     turtle.right(90)
开发者ID:Mertzy,项目名称:ADS,代码行数:11,代码来源:xmlDrawProgram.py


示例12: setup

def setup(col, x, y, w, s, shape): 
    turtle.up()
    turtle.goto(x,y)
    turtle.width(w)
    turtle.turtlesize(s)
    turtle.color(col)
    turtle.shape(shape)
    turtle.bgpic("assets/dancing-banana.gif")
    turtle.down()
    wn.listen()
    turtle.getscreen()._root.bind_all('<Key>', key_pressed)
    turtle.getscreen()._root.mainloop()
开发者ID:kabinud,项目名称:FunPython,代码行数:12,代码来源:turtle_setup.py


示例13: writing

 def writing():
     turtle.width(1)
     turtle.color("white")
     Base((-250,-100))
     turtle.setheading(162)
     turtle.pu()
     turtle.fd(28)
     turtle.setheading(180)
     turtle.fd(10)
     turtle.write("Raphaella and Danes' ", font=("Calibri", 12, "italic"))
     turtle.fd(14)
     turtle.pd()
     turtle.write("   Apple Tree",font = ("Calibri",12,"bold"))
开发者ID:Drellimal2,项目名称:ascii-old-board-games,代码行数:13,代码来源:TurtleTreewithsign+(1).py


示例14: tree

def tree(n,l):
    if n==0:
        return
    turtle.down()
    turtle.width(6*float(n)/max_depth)
    turtle.color(float(n)/max_depth,1-float(n)/max_depth,0.2)
    turtle.forward(l)
    turtle.left(20+turn_scalar*n)
    tree(n-1,l/length_scalar)
    turtle.right(40+2*turn_scalar*n)
    tree(n-1,l/length_scalar)
    turtle.left(20+turn_scalar*n)
    turtle.up()
    turtle.backward(l)
开发者ID:rirwin,项目名称:sandbox,代码行数:14,代码来源:tree.py


示例15: drawBase

def drawBase(size,n,widthh):
	turtle.width(widthh)
	widthh+=.5
	if n<0:
		return
	else:
		turtle.forward(size)
		turtle.left(120)
		for i in range(6):
			turtle.forward(size)
			turtle.left(60)
		turtle.right(120)
		turtle.back(size)
		drawBase(.8*size,n-1,widthh)
	return
开发者ID:wish343,项目名称:Python,代码行数:15,代码来源:SnowFlake.py


示例16: setup

def setup(col, x, y, w, s, shape): 
    turtle.up()
    turtle.goto(x,y)
    turtle.width(w)
    turtle.turtlesize(s)
    turtle.color(col)
    turtle.shape(shape)
    turtle.down()
    wn.onkey(up, "Up")
    wn.onkey(left, "Left")
    wn.onkey(right, "Right")
    wn.onkey(back, "Down")
    wn.onkey(quitTurtles, "Escape")
    wn.listen()
    wn.mainloop()
开发者ID:sharland,项目名称:python_scripts,代码行数:15,代码来源:controllable_turtle.py


示例17: draw_axis

def draw_axis(camera, viewer):
	turtle.width(10)
	X, Y, Z, O = apply_perspective([(300,0,0),(0,300,0),(0,0,300),(0,0,0)],camera,viewer)
	turtle.color(1,0,0)
	turtle.up()
	turtle.goto(O)
	turtle.down()
	turtle.goto(X)
	turtle.goto(O)
	turtle.color(0,1,0)
	turtle.goto(Y)
	turtle.goto(O)
	turtle.color(0,0,1)
	turtle.goto(Z)
	turtle.goto(O)
	turtle.color(0,0,0)
	turtle.width(1)
开发者ID:ChrisCalderon,项目名称:PyShapes,代码行数:17,代码来源:shapes.py


示例18: draw_lines

def draw_lines(lines, color='black', width=3, dots=0, visible=False):
	"""draw every line in lines"""
	turtle.pen(speed=10,shown=False)
	turtle.color(color)
	turtle.width(width)
	for line in lines:
		((x0,y0),(x1,y1)) = list(line)
		turtle.penup()
		turtle.goto((x0,y0))
		turtle.pendown()
		if dots>0: turtle.dot(dots)
		if visible:
#			 turtle.pen(speed=10,shown=True)
			turtle.goto((x1,y1))
#			 turtle.pen(speed=10,shown=False)
		else:
			turtle.goto((x1,y1))
开发者ID:ipmichael,项目名称:cmsc421,代码行数:17,代码来源:tdraw.py


示例19: basic_actions_parametric

 def basic_actions_parametric (cls):
     actions = {}
     actions[Symbol(' ')] = lambda (obj,s) : obj.nop()
     actions[Symbol('[')] = lambda (obj,s) : obj.push()
     actions[Symbol(']')] = lambda (obj,s) : obj.pop()
     actions[Symbol('F')] = lambda (obj,s) : t.forward(s.parameters[0])
     actions[Symbol('!')] = lambda (obj,s) : t.width(s.parameters[0])
     actions[Symbol('+')] = lambda (obj,s) : t.left(s.parameters[0])
     actions[Symbol('-')] = lambda (obj,s) : t.right(s.parameters[0])
     return actions
开发者ID:JJGO,项目名称:Parallel-LSystem,代码行数:10,代码来源:LSystem.py


示例20: drawSquare

def drawSquare(size,depth,number):
	walk=0
	#Base condition
	if depth<1:
		return walk
	#Recursion to draw squares
	elif depth>=1:
		for _ in range(4):
			#Calculating how much turtle walked and drawing at the same time
			walk+=drawSquare(size/3,depth-1,number+1)
			if 0==(number%2):
				turtle.width(1)
			if 0!=(number%2):
				turtle.width(4)
			turtle.forward(size)
			walk+=size
			turtle.left(90)
		#return distance walked
		return walk
开发者ID:wish343,项目名称:Python,代码行数:19,代码来源:Squares.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python turtle.write函数代码示例发布时间:2022-05-27
下一篇:
Python turtle.update函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap