首页 > 分享 > 10个Python绘画表白代码【内附源码,再不收藏你只能单身了】

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】

©著作权归作者所有:来自51CTO博客作者薄荷是计算机学姐的原创作品,谢绝转载,否则将追究法律责任

发现一些很好玩的画图小项目,今天分享给大家,教你怎样用Python画一朵玫瑰花、时钟、爱心、太阳花、月饼、进阶自定义爱心、小猪佩奇、星空、超梦幻的蓝色背景樱花等大家快来学习吧。

运行工具:

pycharm 、python

玫瑰花

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_编程

源码:

from turtle import *
import time

setup(1000,800,0,0)
speed(0)
penup()
seth(90)
fd(340)
seth(0)
pendown()

speed(5)
begin_fill()
fillcolor('red')
circle(50,30)

for i in range(10):
fd(1)
left(10)

circle(40,40)

for i in range(6):
fd(1)
left(3)

circle(80,40)

for i in range(20):
fd(0.5)
left(5)

circle(80,45)

for i in range(10):
fd(2)
left(1)

circle(80,25)

for i in range(20):
fd(1)
left(4)

circle(50,50)

time.sleep(0.1)

circle(120,55)

speed(0)

seth(-90)
fd(70)

right(150)
fd(20)

left(140)
circle(140,90)

left(30)
circle(160,100)

left(130)
fd(25)

penup()
right(150)
circle(40,80)
pendown()

left(115)
fd(60)

penup()
left(180)
fd(60)
pendown()

end_fill()

right(120)
circle(-50,50)
circle(-20,90)

speed(1)
fd(75)

speed(0)
circle(90,110)

penup()
left(162)
fd(185)
left(170)
pendown()
circle(200,10)
circle(100,40)
circle(-52,115)
left(20)
circle(100,20)
circle(300,20)
speed(1)
fd(250)

penup()
speed(0)
left(180)
fd(250)
circle(-300,7)
right(80)
circle(200,5)
pendown()

left(60)
begin_fill()
fillcolor('green')
circle(-80,100)
right(90)
fd(10)
left(20)
circle(-63,127)
end_fill()

penup()
left(50)
fd(20)
left(180)

pendown()
circle(200,25)

penup()
right(150)

fd(180)

right(40)
pendown()
begin_fill()
fillcolor('green')
circle(-100,80)
right(150)
fd(10)
left(60)
circle(-80,98)
end_fill()

penup()
left(60)
fd(13)
left(180)

pendown()
speed(1)
circle(-200,23)

exitonclick()

如果对Python爬虫、数据分析、机器学习、人工智能、面试经验、接单兼职、代码画图、
游戏代码感兴趣可以进到881744585,群内会有不定期的分享学习资料和有趣的代码。还会有技术大牛,业内同行一起交流技术

1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.

实时时钟

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_程序人生_02

源码:

# coding=utf-8

import turtle

from datetime import *

# 抬起画笔,向前运动一段距离放下

def Skip(step):

turtle.penup()

turtle.forward(step)

turtle.pendown()

def mkHand(name, length):

# 注册Turtle形状,建立表针Turtle

turtle.reset()

Skip(-length * 0.1)

# 开始记录多边形的顶点。当前的乌龟位置是多边形的第一个顶点。

turtle.begin_poly()

turtle.forward(length * 1.1)

# 停止记录多边形的顶点。当前的乌龟位置是多边形的最后一个顶点。将与第一个顶点相连。

turtle.end_poly()

# 返回最后记录的多边形。

handForm = turtle.get_poly()

turtle.register_shape(name, handForm)

def Init():

global secHand, minHand, hurHand, printer

# 重置Turtle指向北

turtle.mode("logo")

# 建立三个表针Turtle并初始化

mkHand("secHand", 135)

mkHand("minHand", 125)

mkHand("hurHand", 90)

secHand = turtle.Turtle()

secHand.shape("secHand")

minHand = turtle.Turtle()

minHand.shape("minHand")

hurHand = turtle.Turtle()

hurHand.shape("hurHand")

for hand in secHand, minHand, hurHand:

hand.shapesize(1, 1, 3)

hand.speed(0)

# 建立输出文字Turtle

printer = turtle.Turtle()

# 隐藏画笔的turtle形状

printer.hideturtle()

printer.penup()

def SetupClock(radius):

# 建立表的外框

turtle.reset()

turtle.pensize(7)

for i in range(60):

Skip(radius)

if i % 5 == 0:

turtle.forward(20)

Skip(-radius - 20)

Skip(radius + 20)

if i == 0:

turtle.write(int(12), align="center", font=("Courier", 14, "bold"))

elif i == 30:

Skip(25)

turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))

Skip(-25)

elif (i == 25 or i == 35):

Skip(20)

turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))

Skip(-20)

else:

turtle.write(int(i/5), align="center", font=("Courier", 14, "bold"))

Skip(-radius - 20)

else:

turtle.dot(5)

Skip(-radius)

turtle.right(6)

def Week(t):

week = ["星期一", "星期二", "星期三",

"星期四", "星期五", "星期六", "星期日"]

return week[t.weekday()]

def Date(t):

y = t.year

m = t.month

d = t.day

return "%s %d%d" % (y, m, d)

def Tick():

# 绘制表针的动态显示

t = datetime.today()

second = t.second + t.microsecond * 0.000001

minute = t.minute + second / 60.0

hour = t.hour + minute / 60.0

secHand.setheading(6 * second)

minHand.setheading(6 * minute)

hurHand.setheading(30 * hour)

turtle.tracer(False)

printer.forward(65)

printer.write(Week(t), align="center",

font=("Courier", 14, "bold"))

printer.back(130)

printer.write(Date(t), align="center",

font=("Courier", 14, "bold"))

printer.home()

turtle.tracer(True)

# 100ms后继续调用tick

turtle.ontimer(Tick, 100)

def main():

# 打开/关闭龟动画,并为更新图纸设置延迟。

turtle.tracer(False)

Init()

SetupClock(160)

turtle.tracer(True)

Tick()

turtle.mainloop()

if __name__ == "__main__":

main()

1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.

表白爱心

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_编程_03

源码:

import turtle
import math
turtle.pen()
t=turtle
t.up()
t.goto(0,150)
t.down()
t.color('red')
t.begin_fill()
t.fillcolor('red')
t.speed(1)
t.left(45)
t.forward(150)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(250+math.sqrt(2)*100)
t.right (90)
t.speed(2)
t.forward(250+100*math.sqrt(2))
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(150)
t.end_fill()
t.goto(-10,0)
t.pencolor('white')
#L
t.pensize(10)
t.goto(-50,0)
t.goto(-50,80)
t.up ()
#I
t.goto(-100,0)
t.down()
t.goto(-160,0)
t.goto(-130,0)
t.goto(-130,80)
t.goto(-160,80)
t.goto(-100,80)
t.up()
#O
t.goto(10,25)
t.down()
t.right(45)
t.circle(25,extent=180)
t.goto(60,55)
t.circle(25,extent=180)
t.goto(10,25)
t.up()
t.goto(75,80)
t.down()
t.goto(100,0)
t.goto(125,80)
t.up()
t.goto(180,80)
t.down()
t.goto(140,80)
t.goto(140,0)
t.goto(180,0)
t.up()
t.goto(180,40)
t.down()
t.goto(140,40)
#U
t.up()
t.goto(-40,-30)
t.down()
t.goto(-40,-80)
t.circle(40,extent=180)
t.goto(40,-30)
t.hideturtle()

1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.

小猪佩奇

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_代码_04

源码:

# coding:utf-8
import time
import turtle as t

t.pensize(4)
t.colormode(255)
t.color((255,155,192),"pink")
t.setup(840,500)
t.speed(10)
t.pu()
t.goto(-100,100)
t.pd()
t.seth(-30)
t.begin_fill()
a=0.4
for i in range(120):
if 0<=i<30 or 60<=i<90:
a=a+0.08
t.lt(3)
t.fd(a)
else:
a=a-0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()

t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300,-30)
t.circle(100,-60)
t.circle(80,-100)
t.circle(150,-20)
t.circle(60,-95)
t.seth(161)
t.circle(-300,15)
t.pu()
t.goto(-100,100)
t.pd()
t.seth(-30)
a=0.4
for i in range(60):
if 0<=i<30 or 60<=i<90:
a=a+0.08
t.lt(3)
t.fd(a)
else:
a=a-0.08
t.lt(3)
t.fd(a)
t.end_fill()

t.color((255,155,192),"pink")
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,54)
t.end_fill()
t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,56)
t.end_fill()

t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255,155,192),"white")
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color("black")
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
#腮
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()
#嘴
t.color(239,69,19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30,40)
t.circle(40,80)
#身体
t.color("red",(255,99,71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100,10)
t.circle(300,30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300,30)
t.circle(100,3)
t.color((255,155,192),(255,100,100))
t.seth(-135)
t.circle(-80,63)
t.circle(-150,24)
t.end_fill()
#手
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300,15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20,90)
t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300,15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20,90)
#脚
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color("black")
t.pensize(15)
t.fd(20)
#尾巴
t.pensize(4)
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(60,20)
t.circle(10,230)
t.circle(60,30)

1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.118.119.120.121.122.123.124.125.126.127.128.129.130.131.132.133.134.135.136.137.138.139.140.141.142.143.144.145.146.147.148.149.150.151.152.153.154.155.156.157.158.159.160.161.162.163.164.165.166.167.168.169.170.171.172.173.174.175.176.177.178.179.180.181.182.183.184.185.186.187.188.189.190.191.192.193.194.195.196.197.198.199.200.201.202.203.204.205.206.207.208.209.210.211.212.213.214.215.216.217.218.219.220.221.222.223.224.225.226.227.228.229.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.245.246.247.248.249.250.251.252.253.254.255.256.257.258.259.260.261.262.263.264.265.266.

多角形太阳花

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_程序人生_05

源码:

# coding=utf-8

import turtle

import time

# 同时设置pencolor=color1, fillcolor=color2

turtle.color("red", "yellow")

turtle.begin_fill()

for _ in range(50):

turtle.forward(200)

turtle.left(170)

turtle.end_fill()

turtle.mainloop()

1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.

进阶自定义表白爱心

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_编程_06

模拟3D星空

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_计算机_07

超梦幻的蓝色背景樱花

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_编程_08

花儿

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_程序员_09

表白爱心树

效果图:

10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_程序员_10

其他

其他源码领取可关注我的公众号:白又白学Python

24赞 13收藏 评论 举报

相关文章

简单表白代码java java表白程序代码 如题,微信表白小程序分析3.7号,我们是女生节,班级准备给女生点礼物,我的直男想法就想到了抖音那种表白小程序,感觉或许挺好玩的,就开始制作了制作前先想想用什么语言写比较好.备选项有Python,JAVA,Androidc,c++当时把情况一列我就觉得java的戏比较大.由于本人专业为软件工程,这学期正好开始学习JAVA语言,而且前几天的课就是搭建JAVA环境,所以用户的环境是有的,python我们

简单表白代码java java ide html

相关知识

python浪漫表白,表白代码——绘制3D玫瑰花
python实现元旦倒计时、圣诞树、跨年烟花的绘画马上双旦了给大家带来一些python代码 1.元旦节日倒计时代码的实现
100款 ❤HTML5七夕情人节表白网页源码❤ HTML+CSS+JavaScript 【建议收藏】
基于Python的库存管理系统设计与实现【附源码】
三行代码情书(1)
基于YOLOv8深度学习的智能肺炎诊断系统【python源码+Pyqt5界面+数据集+训练代码】深度学习实战
个人花店网站源码分享,花店网站制作 – 风君子博客
python玫瑰花代码简单
python玫瑰花代码讲解
python 生成玫瑰花代码

网址: 10个Python绘画表白代码【内附源码,再不收藏你只能单身了】 https://m.huajiangbk.com/newsview792227.html

所属分类:花卉
上一篇: 520“我在浏阳说爱你”全城表白
下一篇: 送花表白卡片怎么写,表白送花卡片