Pseudo-original tool [php source code]

Hello everyone, the editor will answer the question of how to run the code for drawing hearts in Python. Many people still don’t know the simple drawing code of love in python, let’s take a look now!

Locomotive collects AI pseudo-original plug-in screenshots:

Draw a heart using Python

Rendering:

Insert image description here

Code part:

import turtle #导入turtle库
turtle.pensize(4)#设置画笔像素为4像素
turtle.pencolor("red")#设置画笔颜色为红色
turtle.fillcolor("pink")#设置填充颜色为粉红色
turtle.begin_fill()#开始填充
#开始绘制爱心
turtle.left(135)
turtle.forward(100)
turtle.circle(-50,180)#第一个半圆
turtle.left(90)
turtle.circle(-50,180)#第二个半圆
turtle.forward(100)
turtle.end_fill()#结束填充
turtle.done()

Drawing method:

The bottom is a square. Add two semicircles on both sides to draw a heart.
Insert image description here

Guess you like

Origin blog.csdn.net/mynote/article/details/132778597