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


Python Turtle.turnLeft方法代码示例

本文整理汇总了Python中turtle.Turtle.turnLeft方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.turnLeft方法的具体用法?Python Turtle.turnLeft怎么用?Python Turtle.turnLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在turtle.Turtle的用法示例。


在下文中一共展示了Turtle.turnLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wraps

# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import turnLeft [as 别名]
# of sides), wraps (an integer specifying a wrap count), and decay
# (a float specifying a decay factor). Draw to standard draw a spiral
# with those characteristics.

n = int(sys.argv[1])
wraps = int(sys.argv[2])
decay = float(sys.argv[3])

angle = 360.0 / n

step = math.sin(math.radians(angle/2.0))
turtle = Turtle(0.5, 0, angle/2.0)

stddraw.setPenRadius(0.0)
stddraw.clear(stddraw.LIGHT_GRAY)
for i in range(wraps * n):
    step /= decay
    turtle.goForward(step)
    turtle.turnLeft(angle)
stddraw.show()
    
#-----------------------------------------------------------------------

# python spiral.py 3 1 1.0

# python spiral.py 3 10 1.2

# python spiral.py 1440 10 1.0004

# python spiral.py 1440 10 1.00004
开发者ID:davidhuizhou,项目名称:python,代码行数:32,代码来源:spiral.py

示例2: int

# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import turnLeft [as 别名]
#-----------------------------------------------------------------------
# drunk.py
#-----------------------------------------------------------------------

import sys
import stdrandom
import stddraw
from turtle import Turtle

#-----------------------------------------------------------------------

# Accept as command-line arguments an integer stepCount specifying a
# number of iterations, and a float stepSize specifying a step size.
# Create a Turtle object, and have it make stepCount random steps of
# size stepSize.

stepCount = int(sys.argv[1])
stepSize = float(sys.argv[2])
stddraw.setPenRadius(0.0)
stddraw.clear(stddraw.LIGHT_GRAY)
myTurtle = Turtle(0.5, 0.5, 0.0)
for i in range(stepCount):
    myTurtle.turnLeft(360.0 * stdrandom.uniformFloat(0.0, 360.0))
    myTurtle.goForward(stepSize)
    stddraw.show(0.0)
stddraw.show()

#-----------------------------------------------------------------------

# python drunk.py 10000 .01
开发者ID:davidhuizhou,项目名称:python,代码行数:32,代码来源:drunk.py


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