本文整理匯總了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')

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,

示例5: draw_pattern_circle

​點讚 6

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

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

示例6: item

​點讚 6

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

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

def item(lenght, level, color):

if level <= 0:

return

for _ in range(5): # 5

turtle.color(colors[color])

turtle.forward(lenght)

item(lenght/4, level-1, color+1)

turtle.penup() # there is no need to draw again the same line (and it can use differnt color)

turtle.backward(lenght)

turtle.pendown()

turtle.right(360/8) # 8

turtle.right(360/8 * 3) # 3 = 8 - 5

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

示例7: move

​點讚 5

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

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

def move(distance):

turtle.penup()

turtle.forward(distance)

turtle.pendown()

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

示例8: createHand

​點讚 5

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

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

def createHand(name, length):

turtle.reset()

move(-length * 0.01)

turtle.begin_poly()

turtle.forward(length * 1.01)

turtle.end_poly()

hand = turtle.get_poly()

turtle.register_shape(name, hand)

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

示例9: createClock

​點讚 5

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

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

示例10: startTick

​點讚 5

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

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

示例11: draw_koch

​點讚 5

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

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

def draw_koch(size, depth):

if depth > 0:

for angle in ANGLES:

draw_koch(size / 3, depth - 1)

turtle.left(angle)

else:

turtle.forward(size)

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

示例12: draw_snowflake

​點讚 5

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

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

def draw_snowflake(size):

""" Draw a picture of a snowflake """

turtle.penup()

turtle.forward(10 * size)

turtle.left(45)

turtle.pendown()

turtle.color(generate_random_colour())

# draw branch 8 times to make a snowflake

for _ in range(8):

draw_branch(size)

turtle.forward(size)

turtle.left(45)

turtle.penup()

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

示例13: draw_branch

​點讚 5

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

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

示例14: draw_square

​點讚 5

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

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

示例15: hexagon

​點讚 5

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

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

def hexagon():

for _ in range(6):

turtle.forward(50)

turtle.left(60)

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

示例16: draw_rectangle

​點讚 5

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

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

def draw_rectangle(size):

for _ in range(4):

turtle.forward(size)

turtle.left(90)

# --- main ---

# clear everything

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

示例17: move

​點讚 5

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

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

def move():

if running:

t.forward(15)

angle = random.randint(-9, 9) * 10

t.left(angle)

t.ontimer(move, 25) # 25ms

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

示例18: forward

​點讚 5

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

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

def forward():

turtle.setheading(90)

turtle.forward(100)

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

示例19: backward

​點讚 5

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

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

def backward():

turtle.setheading(270)

turtle.forward(100)

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

示例20: left

​點讚 5

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

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

def left():

turtle.setheading(180)

turtle.forward(100)

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

示例21: right

​點讚 5

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

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

def right():

turtle.setheading(0)

turtle.forward(100)

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

示例22: draw

​點讚 5

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

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

def draw():

turtle.forward(50)

turtle.left(30)

turtle.forward(50)

turtle.left(30)

# access to tkinter - tk & root

# instead of standard

# import tkinter as tk

# root = tk.Tk()

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

示例23: dragon

​點讚 5

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

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

def dragon(level=1, remove_plus_minus=False, width=5):

a = 'FX'

rule = {

'X': 'X+YF+',

'Y': '-FX-Y',

'-': '-',

'+': '+',

'F': 'F',

}

for _ in range(level):

a = ''.join(rule[x] for x in a)

print('len:', len(a))

a = a.replace('X', '').replace('Y','')

print('len without X, Y:', len(a))

if remove_plus_minus:

a = a.replace('+-', '').replace('-+', '')

print('len without -+, +-:', len(a))

for x in a:

if x == 'F':

turtle.forward(width)

elif x == '+':

turtle.right(90)

turtle.color('red')

elif x == '-':

turtle.left(90)

turtle.color('green')

print('OK')

# --- main ---

# clear everything

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

示例24: flower

​點讚 5

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

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

def flower(size):

for _ in range(36):

turtle.forward(size)

turtle.left(110)

# --- main ---

# clear everything

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

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

python turtle forward_Python turtle.forward方法代碼示例相关推荐

  1. python柱状图zzt_Python torch.diag方法代碼示例

    本文整理匯總了Python中torch.diag方法的典型用法代碼示例.如果您正苦於以下問題:Python torch.diag方法的具體用法?Python torch.diag怎麽用?Python ...

  2. python datetime datetime_Python datetime.tzinfo方法代碼示例

    本文整理匯總了Python中datetime.datetime.tzinfo方法的典型用法代碼示例.如果您正苦於以下問題:Python datetime.tzinfo方法的具體用法?Python da ...

  3. python execute_command err_Python management.execute_from_command_line方法代碼示例

    本文整理匯總了Python中django.core.management.execute_from_command_line方法的典型用法代碼示例.如果您正苦於以下問題:Python manageme ...

  4. python template languages_Python template.TemplateSyntaxError方法代碼示例

    本文整理匯總了Python中django.template.TemplateSyntaxError方法的典型用法代碼示例.如果您正苦於以下問題:Python template.TemplateSynt ...

  5. python time strptime_Python time.strptime方法代碼示例

    本文整理匯總了Python中time.strptime方法的典型用法代碼示例.如果您正苦於以下問題:Python time.strptime方法的具體用法?Python time.strptime怎麽 ...

  6. python的concatetate_Python tensorflow.truncated_normal_initializer方法代碼示例

    本文整理匯總了Python中tensorflow.truncated_normal_initializer方法的典型用法代碼示例.如果您正苦於以下問題:Python tensorflow.trunca ...

  7. python asyncio future_Python asyncio.ensure_future方法代碼示例

    本文整理匯總了Python中asyncio.ensure_future方法的典型用法代碼示例.如果您正苦於以下問題:Python asyncio.ensure_future方法的具體用法?Python ...

  8. python psutil.disk_Python psutil.disk_partitions方法代碼示例

    本文整理匯總了Python中psutil.disk_partitions方法的典型用法代碼示例.如果您正苦於以下問題:Python psutil.disk_partitions方法的具體用法?Pyth ...

  9. python querystring encode_Java UriUtils.encodeQueryParam方法代碼示例

    import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類 private URI buildURI(OTXEndpoints ...

  10. python ndimage.gaussian_Python ndimage.gaussian_gradient_magnitude方法代碼示例

    # 需要導入模塊: from scipy import ndimage [as 別名] # 或者: from scipy.ndimage import gaussian_gradient_magnit ...

最新文章

  1. CoordinatorLayout 之深入理解
  2. 「珍藏」老司机为你推荐10个炫酷的开源库,看完的人都收藏了
  3. Spring AOP(一) AOP基本概念
  4. 轮询没有收到的可能性_轮询(Polling)是什么?
  5. JAVA线程间协作:Condition
  6. java重排序_Java内存模型FAQ(四)重排序意味着什么?
  7. runas/cpau/lsrunase使用小结(以管理员运行指定程序)
  8. redis订阅怎么退出_redis订阅关闭异常解决
  9. (IStool)判断系统位数并打包不同的文件
  10. 了解第三方授权OAuth
  11. 改进:js修改iOS微信浏览器的title
  12. 学校初一模拟赛(2019.4.20)
  13. Supervisor管理springboot应用
  14. u盘上传百度网盘照片显示服务器错误,百度云上传文件失败怎么办-百度云上传文件失败的解决方法 - 河东软件园...
  15. FCN全卷积网络和Deconv转置卷积原理描述
  16. Day 11. Evidence for a mental health crisis in graduate education
  17. 深圳英语培训班有推荐的吗?学习效果好吗?
  18. 今日头条号怎么赚钱,个人通过今日头条如何赚钱的方法
  19. 物联网开发之智慧农业解决方案
  20. MySQL 5.7 修改账号密码

热门文章

  1. Thinkpad预装win10硬盘分区
  2. 状态机的编写(使用C++)
  3. java-setBounds方法
  4. usb Android gentoo,gentoo usb 鼠标
  5. 哈里王子与魔兽圣骑士(Paladin)
  6. 微服务: 立志做个伟大的项目
  7. 无线网络有信号显示未连接网络连接服务器,路由器无线网络受限制或无连接怎么办...
  8. js:Cannot use import statement outside a module
  9. 微信授权 昵称显示微信用户、无头像
  10. 史上最详细Lip-reading with Hierarchical Pyramidal Convolution and Self-Attention文章记录