Python中如何进行绘制对称图形,方法有哪些
Admin 2022-07-27 群英技术资讯 2346 次浏览
今天小编跟大家讲解下有关“Python中如何进行绘制对称图形,方法有哪些”的内容 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了相关资料,希望小伙伴们看了有所帮助。第一个图是由三角形组成的花,感兴趣的小伙伴可以自己尝试在python中用turtle库绘制一下。

具体代码如下:
# -*- coding: UTF-8 -*-
'''
代码用途 :画对称图形
作者 :阿黎逸阳
博客 : https://blog.csdn.net/qq_32532663/article/details/106176609
'''
import os
import time
import pygame
import turtle as t
t.title('阿黎逸阳的代码公众号')
t.speed(10)
t.setup(startx=0, starty = 0, width=800, height = 600)
#第一幅图
def w_sg1(theta):
t.setheading(theta)
t.color('green')
t.begin_fill()
t.forward(60)
t.left(100)
t.forward(20)
t.left(100)
t.forward(60)
t.end_fill()
for i in range(8):
w_sg1(70 + i*45)
t.hideturtle()
第二个图是旋风轮,怎么通过调整图1代码,绘制出如下图形?

具体代码如下:
# -*- coding: UTF-8 -*-
'''
代码用途 :画对称图形
作者 :阿黎逸阳
博客 : https://blog.csdn.net/qq_32532663/article/details/106176609
'''
import os
import time
import pygame
import turtle as t
t.title('阿黎逸阳的代码公众号')
t.speed(10)
t.setup(startx=0, starty = 0, width=800, height = 600)
#第二幅图
def w_sg2(theta):
t.setheading(theta)
t.color('green')
t.begin_fill()
t.forward(55)
t.left(100)
t.forward(20)
t.left(100)
t.forward(60)
t.end_fill()
for i in range(24):
w_sg2(70 + i*15)
t.hideturtle()
第三个图是八叶花,你也可以试着把叶子改成别的颜色。

具体代码如下:
# -*- coding: UTF-8 -*-
'''
代码用途 :画对称图形
作者 :阿黎逸阳
博客 : https://blog.csdn.net/qq_32532663/article/details/106176609
'''
import os
import time
import pygame
import turtle as t
t.title('阿黎逸阳的代码公众号')
t.speed(10)
t.setup(startx=0, starty = 0, width=800, height = 600)
#第三幅图
def w_sg3(theta):
t.color('green')
t.begin_fill()
t.setheading(theta)
t.circle(80, 50)
t.left(130)
t.circle(80, 50)
t.end_fill()
for i in range(8):
w_sg3(30 + i*45)
t.hideturtle()
第四个图是16叶花,怎么通过调整8叶花代码,绘制出如下图形?

具体代码如下:
t.clearscreen()
#第四幅图
for i in range(16):
w_sg3(30 + i*30)
t.hideturtle()
t.goto(0, -3)
t.color('white')
t.begin_fill()
t.circle(6, 360)
t.end_fill()
第五个图是小太阳,怎么通过调整8叶花代码,绘制出如下图形?

具体代码如下:
# -*- coding: UTF-8 -*-
'''
代码用途 :画对称图形
作者 :阿黎逸阳
博客 : https://blog.csdn.net/qq_32532663/article/details/106176609
'''
import os
import time
import pygame
import turtle as t
t.title('阿黎逸阳的代码公众号')
t.speed(10)
t.setup(startx=0, starty = 0, width=800, height = 600)
#第五幅图
def w_sg3(theta):
t.color('red')
t.begin_fill()
t.setheading(theta)
t.circle(80, 50)
t.left(130)
t.circle(80, 50)
t.end_fill()
for i in range(24):
w_sg3(30 + i*15)
t.hideturtle()
第六个图是阴阳图。

具体代码如下:
# -*- coding: UTF-8 -*-
'''
代码用途 :画对称图形
作者 :阿黎逸阳
博客 : https://blog.csdn.net/qq_32532663/article/details/106176609
'''
import os
import time
import pygame
import turtle as t
t.title('阿黎逸阳的代码公众号')
t.speed(10)
t.setup(startx=0, starty = 0, width=800, height = 600)
#阴阳图
def w_sg4():
t.color('black')
t.begin_fill()
t.circle(80, 360)
t.end_fill()
t.color('black', 'white')
t.begin_fill()
t.circle(80, 180)
t.circle(40, 180)
t.circle(-40, 180)
t.end_fill()
t.penup()
t.goto(0, 130)
t.pendown()
t.begin_fill()
t.color('black')
t.circle(8, 360)
t.end_fill()
t.penup()
t.goto(0, 130-90)
t.pendown()
t.begin_fill()
t.color('white')
t.circle(8, 360)
t.end_fill()
t.hideturtle()
w_sg4()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
python的jieba库干什么的?一些刚接触Python的朋友可能对jieba库不是很了解,因此这篇文章就给大家来介绍一下,jieba库的作用、jieba库的安装以及jieba库的使用,感兴趣的朋友就继续往下看吧。
这篇文章主要介绍了python 判断字符串当中是否包含字符(str.contain),文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本章节主要说明Python的运算符。Python 语言支持以下类型的运算符:算术运算符、比较(关系)运算符、赋值运算符、逻辑运算符、位运算符、成员运算符、身份运算符、运算符优先级_
在web 开发过程中,Django 与后台数据库的交互是必不可少的一项,也是实现业务逻辑所需数据的重要方式,这篇文章主要给大家介绍了关于Django中常用的查询数据方法及查询对象条件的相关资料,需要的朋友可以参考下
Python中没有报错提示,其中使用了 try-except-else 的代码块,except是try代码中错误时执行,而except中的代码是pass,也就是在try中代码错误时候直接pass,不给用户编写任何的建议和help。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008