首页 > 分享 > Python学习笔记四(turtle模块画图练习)

Python学习笔记四(turtle模块画图练习)

最新推荐文章于 2024-10-17 17:08:11 发布

CY呵 于 2019-03-27 10:48:07 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

Turtle画图:

import turtle as t

t.speed(5)

t.penup()

t.goto(0,200)

t.pendown()

t.circle(-200)

t.penup()

for i in range(4):

t.setheading((3-i)*90)

t.pendown()

t.circle(200, 90)

t.penup()

 Turtle画图:如图

import turtle as t

t.speed(5)

t.penup()

t.goto(-100,100)

for i in range(4):

t.setheading((3-i)*90)

t.pendown()

t.circle(100,180)

t.penup()

Turtle画图:四瓣花,每一瓣由半径为100像素半圆弧的组成,如下图:

import turtle as t

t.speed(5)

t.penup()

t.goto(-100,-100)

t.setheading(270)

for i in range(4):

t.pendown()

t.circle(100,180)

t.penup()

t.setheading(i*90)

Turtle绘制如下图形:

import turtle as t

t.speed(5)

t.penup()

for a in range(3):

t.home()

t.setheading(120 * a)

t.pendown()

t.color("black", "black")

t.begin_fill()

t.forward(100)

t.left(60)

t.forward(100)

t.left(120)

t.forward(100)

t.left(60)

t.forward(100)

t.end_fill()

t.penup()

Turtle绘制图形:

import turtle as t

t.speed(5)

t.pensize(3)

t.pendown()

for i in [90,270]:

t.setheading(i)

t.color("red", "Black")

t.begin_fill()

t.circle(100, steps=3)

t.end_fill()

t.penup()

t.home()

t.goto(0,-15)

t.pendown()

t.color("red","Black")

t.begin_fill()

t.circle(15)

t.end_fill()

t.penup()

Turtle绘制斯诺特图形,如下:

import turtle as t

t.speed(5)

t.penup()

def Srt(r, n):

for a in range(0, n):

t.goto(0, -100)

t.setheading(120)

t.forward(2 * r * a)

t.setheading(0)

for b in range(0, a + 1):

t.pendown()

t.circle(r)

t.penup()

t.forward(2*r)

Srt(20,5)

制斯诺特图形思路图:(我绘图的思路图,也不知道除了我,会不会有人看懂.....自己理得都有点费劲,应该不是最简的方法,但想不出其他的了......)

相关知识

python 绘制一个四瓣花图
python用turtle画玫瑰花
使用Python的turtle模块绘制玫瑰花图案(含详细Python代码与注释)
python中turtle画三朵玫瑰
python的turtle画个玫瑰花
使用Python的turtle模块绘制花形图案(含详细Python代码与注释)
用python turtle绘制一朵玫瑰花
python玫瑰花代码讲解
【Python绘画】花朵
python玫瑰花代码简单

网址: Python学习笔记四(turtle模块画图练习) https://m.huajiangbk.com/newsview856043.html

所属分类:花卉
上一篇: 同济大学2020年大一转专业(风
下一篇: 简单几步教你画清新迷人的水彩画,