来源于网上短视频
数学原理不懂,图个乐
import math
from turtle import *def x(i):return 15 * math.sin(i) ** 3 * 20def y(i):return 20 * (12 * math.cos(i) - 5 * math.cos(2 * i) - 2 * math.cos(4 * i))speed(0)
color('red')
pensize(10)
for i in range(512):goto(x(i), y(i))goto(0, 0)
done()
import turtle
# 设置画笔颜色和线条宽度
turtle.color('red', 'pink') # 前景色(线条颜色),背景色(填充颜色)
turtle.pensize(3)
# 移动一下起笔位置
turtle.penup()
turtle.goto(0, -140)
turtle.pendown()
# 绘制爱心
turtle.begin_fill()
turtle.setheading(140)
turtle.forward(180)
turtle.circle(-90, 200)
turtle.left(120)
turtle.circle(-90, 200)
turtle.forward(180)
turtle.end_fill()
# 点击关闭窗口
turtle.done()
全部换成红色
import turtle
# 设置画笔颜色和线条宽度
turtle.color('red', 'red') # 前景色(线条颜色),背景色(填充颜色)
turtle.pensize(3)
# 移动一下起笔位置
turtle.penup()
turtle.goto(0, -140)
turtle.pendown()
# 绘制爱心
turtle.begin_fill()
turtle.setheading(140)
turtle.forward(180)
turtle.circle(-90, 200)
turtle.left(120)
turtle.circle(-90, 200)
turtle.forward(180)
turtle.end_fill()
# 点击关闭窗口
turtle.done()