python中right_Python turtle.right方法代碼示例

本文详细介绍了Python中的turtle模块中right方法的用法示例,涵盖从绘制树形结构到创建齿轮、图案、时钟等图形,适合初学者理解基本转向操作。通过12个代码实例展示,助你快速掌握在turtle绘图中的转向技巧。
摘要由CSDN通过智能技术生成

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

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

示例1: draw_tree

​點讚 7

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_tree(length, width=9):

color = 'brown'

if length < 1:

return

elif length < 3:

color = 'green'

if width < 1:

width = 1

turtle.color(color)

turtle.width(width)

turtle.forward(length)

turtle.left(30)

draw_tree(length / FACTOR, width - 1)

turtle.right(60)

draw_tree(length / FACTOR, width - 1)

turtle.left(30)

turtle.color(color)

turtle.width(width)

turtle.backward(length)

開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:23,

示例2: gear

​點讚 6

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def gear(count, width, height):

angle = 90-(180/count)

for _ in range(count):

turtle.forward(width)

turtle.left(angle)

turtle.forward(height)

turtle.right(90)

turtle.forward(width)

turtle.right(90)

turtle.forward(height)

turtle.left(angle)

# --- main ---

# clear everything

開發者ID:furas,項目名稱:python-examples,代碼行數:19,

示例3: draw_pattern_rectangle

​點讚 6

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_pattern_rectangle(x, y, width, height, count, radius, color='red'):

rotation = 360 / count

turtle.goto(x, y)

for _ in range(count):

# move from center to circle

turtle.pu()

#turtle.color('black')

turtle.forward(radius)

turtle.right(90+rotation/2)

draw_rectangle(width, height, color)

# move from circle to center

turtle.pu()

#turtle.color('black')

turtle.left(90+rotation/2)

turtle.backward(radius)

# rotate in circle

turtle.right(rotation)

開發者ID:furas,項目名稱:python-examples,代碼行數:24,

示例4: draw_pattern_circle

​點讚 6

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_pattern_circle(x, y, r, count, radius, color='red'):

rotation = 360 / count

turtle.goto(x, y)

for _ in range(count):

# move from center to circle

#turtle.pu()

turtle.color('black')

turtle.forward(radius)

turtle.right(90)

draw_circle(r, color)

# move from circle to center

#turtle.pu()

turtle.color('black')

turtle.left(90)

turtle.backward(radius)

# rotate in circle

turtle.right(rotation)

開發者ID:furas,項目名稱:python-examples,代碼行數:24,

示例5: createClock

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def createClock(radius):

turtle.reset()

turtle.pensize(7)

for i in range(60):

move(radius)

if i % 5 == 0:

turtle.forward(20)

move(-radius-20)

else:

turtle.dot(5)

move(-radius)

turtle.right(6)

開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:14,

示例6: startTick

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [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,

示例7: draw_branch

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_branch(size):

""" Draw an individual branch on a snowflake """

side_branch_size = size / 3

for _ in range(3):

for i in range(3):

turtle.forward(side_branch_size)

turtle.backward(side_branch_size)

turtle.right(45)

turtle.left(90)

turtle.backward(side_branch_size)

turtle.left(45)

turtle.right(90)

開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:14,

示例8: draw_square

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_square(size):

""" Function to draw a square """

turtle.forward(size)

turtle.right(90)

turtle.forward(size)

turtle.right(90)

turtle.forward(size)

turtle.right(90)

turtle.forward(size)

開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:11,

示例9: draw_square

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_square(size):

""" Draw a square in the current direction """

turtle.forward(size)

turtle.right(90)

turtle.forward(size)

turtle.right(90)

turtle.forward(size)

turtle.right(90)

turtle.forward(size)

開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:11,

示例10: draw_1

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_1(length, level):

if level < 1:

turtle.fd(length)

else:

length = length/3

draw_1(length, level-1)

turtle.left(90)

draw_1(length, level-1)

turtle.right(90)

draw_1(length, level-1)

turtle.right(90)

draw_1(length, level-1)

turtle.left(90)

draw_1(length, level-1)

開發者ID:furas,項目名稱:python-examples,代碼行數:17,

示例11: draw_2

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def draw_2(length, level):

if level < 1:

turtle.fd(length)

else:

length = length/3

draw_2(length, level-1)

turtle.left(60)

draw_2(length, level-1)

turtle.right(180-60)

draw_2(length, level-1)

turtle.left(60)

draw_2(length, level-1)

開發者ID:furas,項目名稱:python-examples,代碼行數:15,

示例12: turn_right

​點讚 5

# 需要導入模塊: import turtle [as 別名]

# 或者: from turtle import right [as 別名]

def turn_right(width, step, draw):

for _ in range(4):

draw(width, step)

turtle.right(90)

# --- main ---

# clear everything

開發者ID:furas,項目名稱:python-examples,代碼行數:10,

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值