python海龟绘图_Python教学案例|海龟绘图三例
生活随笔
收集整理的這篇文章主要介紹了
python海龟绘图_Python教学案例|海龟绘图三例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
說明:海龜繪圖網上的案例非常多,網上百度一搜就可以找到各種各樣的不同繪圖參考代碼,簡單的有,難的有繪制梵高畫、九大行星圖等等,有需求的最好問度娘,簡單又方便。
分享Python?基礎教程:
https://www.runoob.com/python/python-tutorial.html
01
四色彩色螺旋線
from turtle import *from time import *
import turtle
t = Turtle()
t.pensize(2)
turtle.bgcolor("black")
colors = ["red", "yellow", 'purple', 'blue']
t._tracer(False)for x in range(200):
t.forward(2*x)
t.color(colors[x % 4])
t.left(91)
t._tracer(True)done()
02
六色彩色螺旋線
from turtle import *from time import *
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
sides=6
colors = ["red", "yellow", "blue", "orange", "green", "purple"]for x in range(100):
t.pencolor(colors[x%sides])
t.forward(x * 3/sides + x)
t.left(360/sides + 1)
t.width(x*sides/200)
t._tracer(True)done()
03
彩色炫酷圖
import turtlet = turtle.Pen()
turtle.bgcolor("black")
sides=6
colors=["red","yellow","green","blue","orange","purple"]for x in range(360):
t.pencolor(colors[x%sides])
t.forward(x*3/sides+x)
t.left(360/sides+1)
t.width(x*sides/180)
t.left(91)
END
總結
以上是生活随笔為你收集整理的python海龟绘图_Python教学案例|海龟绘图三例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot 引入jdbc驱动_
- 下一篇: 学生用计算机怎么用视频,19.使用ZOO