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


Python turtle.width函数代码示例

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


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


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