python forward(10)什么意思-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")
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 forward(10)什么意思-Python turtle.forward方法代码示例相关推荐
- python color属性_Python turtle.color方法代码示例
本文整理汇总了Python中turtle.color方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.color方法的具体用法?Python turtle.color怎么用?P ...
- python end用法_Python turtle.end_fill方法代码示例
本文整理汇总了Python中turtle.end_fill方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.end_fill方法的具体用法?Python turtle.end_ ...
- python中right是什么意思_Python turtle.right方法代码示例
本文整理汇总了Python中turtle.right方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.right方法的具体用法?Python turtle.right怎么用?P ...
- python中stringvar的用法_Python tkinter.StringVar方法代码示例
本文整理汇总了Python中tkinter.StringVar方法的典型用法代码示例.如果您正苦于以下问题:Python tkinter.StringVar方法的具体用法?Python tkinter ...
- python中formatter的用法_Python pyplot.FuncFormatter方法代码示例
本文整理汇总了Python中matplotlib.pyplot.FuncFormatter方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.FuncFormatter方法的具体 ...
- python中bind的用法_Python socket.bind方法代码示例
本文整理汇总了Python中socket.bind方法的典型用法代码示例.如果您正苦于以下问题:Python socket.bind方法的具体用法?Python socket.bind怎么用?Pyth ...
- python中font的用法_Python font.nametofont方法代码示例
本文整理汇总了Python中tkinter.font.nametofont方法的典型用法代码示例.如果您正苦于以下问题:Python font.nametofont方法的具体用法?Python fon ...
- python实现k core算法_Python core.take方法代码示例
# 需要导入模块: from numpy import core [as 别名] # 或者: from numpy.core import take [as 别名] def test_equal_to ...
- Python Django 多表插入之重写save()方法代码示例
- python recvfrom函数详解_Python socket.recvfrom方法代码示例
# 需要导入模块: import socket [as 别名] # 或者: from socket import recvfrom [as 别名] def __discover_device__(se ...
最新文章
- Python将被加入高考科目?你怎么看?
- 面向对象的多态性(1)
- 【图像分类】从数据集和经典网络开始
- 一步一步教你如何将 yolov3/yolov4 转为 caffe 模型
- 简单QT应用到通过手写布局实现QT应用
- 需求澄清_澄清字符串的格式!
- Django框架(展示图书信息简易版)
- OpenCL用于计算机领域的13个经典案例
- 【codevs2912】反素数,好好学习天天向上
- 讲解开源项目:让你成为灵魂画手的 JS 引擎:Zdog
- tornado(五)
- 【供应链架构day10】供应链架构的基础逻辑
- 关于sematic segmentation的几篇论文(二)
- 基于长短期记忆神经网络的蛋白质二级结构预测
- 一堆Offer怎么选?这样做就不纠结了
- JavaWeb --MYSql(MySql基础,MySql高级,JDBC,从类路径下加载输入流对象)
- perl各个符号代表的意思
- 计算机术语中英文对照
- 最强 IDE Visual Studio 2017 正式版发布-gt;最快更高效-终于等到你
- excel数据分析案例——电信运营商用户流失分析
热门文章
- 华为机试HJ26:字符串排序
- 寄存器间接寻址缺点_详解西门子间接寻址之地址寄存器间接寻址
- 怎么只要小数部分C语言,如何得出一个浮点数的小数部分,要把各个位保存到一个数组里边。...
- wdatepicker不显示秒_为什么别人电脑开机只要3秒,你有固态硬盘却要等上18秒?...
- python实践项目(六)
- Go WebSocket开发与测试实践【gorilla/websocket】
- 谈谈我在敏捷开发中遇到的那些坑
- ssr机场_史丹索普SSR草莓绑苗工作两周
- PAT甲级 1003 Dijkstra的口诀干货
- 1、css引入的方式有哪些?_低氮燃烧技术都有哪些?