python turtle forward_Python turtle.forward方法代碼示例

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

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

示例1: draw_tree

​點讚 7

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

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

​點讚 6

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

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

def square(x, y, size, name):

"""Draw square at `(x, y)` with side length `size` and fill color `name`.

The square is oriented so the bottom left corner is at (x, y).

"""

import turtle

turtle.up()

turtle.goto(x, y)

turtle.down()

turtle.color(name)

turtle.begin_fill()

for count in range(4):

turtle.forward(size)

turtle.left(90)

turtle.end_fill()

開發者ID:PacktPublishing,項目名稱:Learning-Python-by-building-games,代碼行數:20,

示例3: gear

​點讚 6

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

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

示例4: draw_pattern_rectangle

​點讚 6

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

# 或者: from turtle import forward [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')

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值