上面是直接画的,没有填充,接下来我们画一个有填充的。
也可以添加好看的背景噢。
二、程序代码
代码将在下面解释,可以看着代码对应下面的函数解释。
第一种:
import turtle
import math
turtle.title("照彻乾坤,印透山河")
turtle.bgpic("yueliang/1.png")
p = turtle.Turtle()
p.pensize(4)
p.speed(3)
#做月饼的面
def ellipse(a,b,n=500,c='#CD950C'):
p.penup()
p.setpos(a,0)
color = p.color(c)
p.pendown()
for i in range(n):
radian = 2 * math.pi /n
theta = (i+1) * radian
next_point = (a * math.cos(theta)),b * math.sin(theta)
p.setpos(next_point)
ellipse(300,200,c='#CD950C')
ellipse(296,196,c='#FFB90F')
ellipse(292,192,c='#FFD700')
#做月饼的底
turtle.penup()
turtle.goto(-10,-300)
turtle.color("#CD950C")
turtle.pensize(6)
turtle.pendown()
turtle.circle(430,42)#33
turtle.circle(420,-84)#-60
turtle.goto(-296,-40)
turtle.penup()
turtle.goto(296,-40)
turtle.pendown()
turtle.right(54)
turtle.forward(151)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
def draw(a1,b1,a2,b2,f='#CD950C'):#边角的2个点,分别是(a1,b1),(a2,b2)
turtle.penup()
turtle.goto(a1,b1)
turtle.pensize(6)
turtle.color(f)
turtle.pendown()
turtle.goto(a2,b1)
turtle.goto(a2,b2)
turtle.penup()
return()
#下面是4个角图案
draw(260,78,130,170,'#FFD700')
draw(250,90,150,160)
draw(240,102,172,150)
draw(230,114,194,140)
draw(-260,-78,-130,-170,'#FFD700')
draw(-250,-90,-150,-160)
draw(-240,-102,-172,-150)
draw(-230,-114,-194,-140)
draw(260,-78,130,-170,'#FFD700')
draw(250,-90,150,-160)
draw(240,-102,172,-150)
draw(230,-114,194,-140)
draw(-262,78,-130,170,'#FFD700')
draw(-250,90,-150,160)
draw(-240,102,-172,150)
draw(-230,114,-194,140)
turtle.penup()
turtle.pensize(6)
turtle.color("#CD950C")
turtle.goto(-270,66)
turtle.pendown()
turtle.goto(-150,66)
turtle.goto(-150,-66)
turtle.goto(-270,-66)
turtle.goto(-270,-54)
turtle.goto(-170,-54)
turtle.goto(-170,54)
turtle.goto(-276,54)
turtle.goto(-276,42)
turtle.goto(-190,42)
turtle.goto(-190,-42)
turtle.goto(-276,-42)
turtle.goto(-276,-30)
turtle.goto(-210,-30)
turtle.goto(-210,30)
turtle.goto(-279,30)
turtle.goto(-279,18)
turtle.goto(-230,18)
turtle.goto(-230,-18)
turtle.goto(-282,-18)
turtle.goto(-282,-2)
turtle.goto(-258,-2)
turtle.penup()
turtle.penup()
turtle.goto(-128,-2)
turtle.pendown()
turtle.color("#FFD700")
turtle.pensize(2)
turtle.goto(126,-2)
turtle.penup()
turtle.penup()
turtle.pensize(6)
turtle.color("#CD950C")
turtle.goto(270,66)
turtle.pendown()
turtle.goto(150,66)
turtle.goto(150,-66)
turtle.goto(270,-66)
turtle.goto(270,-54)
turtle.goto(170,-54)
turtle.goto(170,54)
turtle.goto(276,54)
turtle.goto(276,42)
turtle.goto(190,42)
turtle.goto(190,-42)
turtle.goto(276,-42)
turtle.goto(276,-30)
turtle.goto(210,-30)
turtle.goto(210,30)
turtle.goto(279,30)
turtle.goto(279,18)
turtle.goto(230,18)
turtle.goto(230,-18)
turtle.goto(282,-18)
turtle.goto(282,-2)
turtle.goto(258,-2)
turtle.penup()
turtle.penup()
turtle.pensize(6)
turtle.color("#CD950C")
turtle.goto(-110,174)
turtle.pendown()
turtle.goto(-110,90)
turtle.goto(110,90)
turtle.goto(110,174)
turtle.goto(90,174)
turtle.goto(90,102)
turtle.goto(-90,102)
turtle.goto(-90,176)
turtle.goto(-70,176)
turtle.goto(-70,114)
turtle.goto(70,114)
turtle.goto(70,176)
turtle.goto(50,176)
turtle.goto(50,126)
turtle.goto(-50,126)
turtle.goto(-50,180)
turtle.goto(-30,180)
turtle.goto(-30,138)
turtle.goto(30,138)
turtle.goto(30,182)
turtle.goto(10,182)
turtle.goto(-10,182)
turtle.goto(-10,150)
turtle.goto(10,150)
turtle.goto(10,166)
turtle.penup()
turtle.penup()
turtle.goto(10,76)
turtle.pendown()
turtle.pensize(2)
turtle.color("#FFD700")
turtle.goto(10,-75)
turtle.penup()
turtle.penup()
turtle.pensize(6)
turtle.color("#CD950C")
turtle.goto(-110,-174)
turtle.pendown()
turtle.goto(-110,-90)
turtle.goto(110,-90)
turtle.goto(110,-174)
turtle.goto(90,-174)
turtle.goto(90,-102)
turtle.goto(-90,-102)
turtle.goto(-90,-176)
turtle.goto(-70,-176)
turtle.goto(-70,-114)
turtle.goto(70,-114)
turtle.goto(70,-176)
turtle.goto(50,-176)
turtle.goto(50,-126)
turtle.goto(-50,-126)
turtle.goto(-50,-180)
turtle.goto(-30,-180)
turtle.goto(-30,-138)
turtle.goto(30,-138)
turtle.goto(30,-182)
turtle.goto(10,-182)
turtle.goto(-10,-182)
turtle.goto(-10,-150)
turtle.goto(10,-150)
turtle.goto(10,-166)
turtle.penup()
#中间金色边框
turtle.penup()
turtle.goto(-130,170)
draw(-130,78,130,-78,'#FFD700')
draw(130,-78,-130,78,'#FFD700')
turtle.penup()
#中间金色字体
turtle.penup()
turtle.speed(1)
turtle.penup()
turtle.goto(-100,0)
turtle.pendown()
turtle.color('#D2691E')
turtle.write("花",font=("隶书",60,"bold"))
turtle.penup()
turtle.goto(30,0)
turtle.pendown()
turtle.write("好",font=("隶书",60,"bold"))
turtle.penup()
turtle.goto(-100,-80)
turtle.pendown()
turtle.write("月",font=("隶书",60,"bold"))
turtle.penup()
turtle.goto(30,-80)
turtle.pendown()
turtle.write("圆",font=("隶书",60,"bold"))
turtle.penup()
p.hideturtle()
turtle.mainloop()
第二种:
import turtle
turtle.title("祝大家中秋节快乐!")
# turtle.bgpic("hua/1.png")
turtle.speed(100)
turtle.color("#F5E16F")
for i in range(20):
# 顺时针移动18度
turtle.right(18)
turtle.begin_fill()
# 向前移动的距离
turtle.forward(220)
# 画半径为 40 的半圆
turtle.circle(40, 180)
# 画完半圆之后回到(0,0)
turtle.goto(0, 0)
turtle.right(360)
turtle.end_fill()
# 设置画笔粗细
turtle.pensize(20)
# 填充颜色(外部、内部)
turtle.color("#F5E16F", "#FF9933")
turtle.goto(0, -200)
# 准备开始填充
turtle.begin_fill()
turtle.circle(200)
# 填充结束
turtle.end_fill()
turtle.right(360)
turtle.color('#F5E16F')
turtle.goto(0, -180)
for i in range(12):
turtle.begin_fill()
turtle.circle(60, 120)
turtle.left(180)
turtle.circle(60, 120)
turtle.end_fill()
turtle.penup()
turtle.goto(-80,-40)
turtle.pendown()
turtle.color("#F5E16F")
turtle.write("团圆", font=("隶书", 60, "bold"))
turtle.mainloop()
三、素材背景
将图片放在文件夹中
本文将1.png放在yueliang文件夹中
1.png
2.png
3.png
更多的背景可以在网上搜索获得。
四、原理解释
1、概念
学好 Python 不论是就业还是做副业赚钱都不错,但要学会 Python 还是要有一个学习规划。最后大家分享一份全套的 Python 学习资料,给那些想学习 Python 的小伙伴们一点帮助!
一、Python所有方向的学习路线
Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。
二、学习软件
工欲善其事必先利其器。学习Python常用的开发软件都在这里了,给大家节省了很多时间。
三、全套PDF电子书
书籍的好处就在于权威和体系健全,刚开始学习的时候你可以只看视频或者听某个人讲课,但等你学完之后,你觉得你掌握了,这时候建议还是得去看一下书籍,看权威技术书籍也是每个程序员必经之路。
四、入门学习视频
我们在看视频学习的时候,不能光动眼动脑不动手,比较科学的学习方法是在理解之后运用它们,这时候练手项目就很适合了。
五、实战案例
光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。
六、面试资料
我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。