「Python绘图」绘制太极图

python 绘制太极

一、预期结果

二、核心代码

import turtle

pen = turtle.Turtle()

print("开始绘制太极")

radius = 100
pen.color("black", "black")
pen.begin_fill()
pen.circle(radius/2, 180)
pen.circle(radius, 180)
pen.left(180)
pen.circle(-radius/2, 180)
pen.end_fill() 


pen.left(90)
pen.pu()
pen.fd(radius*0.35)
pen.right(90)
pen.pd()

print("绘制小圆")
pen.color("white", "white")
pen.begin_fill()
pen.circle(radius*0.15)
pen.end_fill() 


pen.left(90)
pen.up()
pen.backward(radius*0.7)
pen.down()
pen.left(90)

print("绘制小圆")
pen.color("black", "black")
pen.begin_fill()
pen.circle(radius*0.15)
pen.end_fill()

print("补大圆")
pen.right(90)
pen.pu()
pen.backward(radius*0.65)
pen.right(90)
pen.pd()
pen.circle(radius, 180)
print("绘制完成")
pen.ht()
turtle.done()
相关推荐
xinxiyinhe19 分钟前
如何设置Cursor中.cursorrules文件
人工智能·python
风与沙的较量丶29 分钟前
Java中的局部变量和成员变量在内存中的位置
java·开发语言
水煮庄周鱼鱼36 分钟前
C# 入门简介
开发语言·c#
诸神缄默不语1 小时前
如何用Python 3自动打开exe程序
python·os·subprocess·python 3
橘子师兄1 小时前
分页功能组件开发
数据库·python·django
编程星空1 小时前
css主题色修改后会多出一个css吗?css怎么定义变量?
开发语言·后端·rust
软件黑马王子1 小时前
Unity游戏制作中的C#基础(6)方法和类的知识点深度剖析
开发语言·游戏·unity·c#
Logintern091 小时前
使用VS Code进行Python编程的一些快捷方式
开发语言·python
Multiple-ji2 小时前
想学python进来看看把
开发语言·python
一个小白12 小时前
C++——list模拟实现
开发语言·c++