找到一个挺漂亮的图片,我们试着用python把它画出来。
打算的构图:
1.富士山 2.花田 3.樱花树 4.樱花雨
第一步,导入绘图库,建立画布,找准坐标,做到心中有数
import turtle as t
t.setup(800,600,0,0)
画布中心为(0,0),左右边界(-400,400)上下边界(-300,300)
第二步 1,填充背景色
https://tool.oschina.net/commons?type=3
在网络上选择一个RGB颜色对照表
t.bgcolor('Thistle') # 背景色
2.画富士山
选择富士山的颜色:深蓝色
t.fillcolor('RoyalBlue3')
t.begin_fill()
t.seth(15)
t.circle(800,15)
print('雪山左标记点:',t.position())
t.circle(800,15)
在这里之所以不一次性把弧形画完,是因为想找出这个点,方便后面画山上的积雪。
用到turtle.position()调出此刻的坐标。
t.seth(-15)
t.circle(250,30)
这是山顶的弧线
t.seth(-50)
t.circle(800,15)
print('雪山右标记点:', t.position())
t.circle(800, 15)
山右侧的弧线
t.end_fill()
结束山体颜色(深蓝色)填充
3.画积雪
t.fillcolor('Snow2')
t.begin_fill()
jumpTo(-207.06,79.92)#左标记点
t.seth(30)
t.circle(800, 15)#左半弧
t.seth(-15)
t.circle(250, 30)#上弧
t.seth(-50)
t.circle(800, 15) #右弧
t.seth(-142)
t.circle(-350,80) #下弧
t.end_fill()
跳至刚才的标记点圈出积雪范围,填充挑选和的颜色
3.花田,大体方法同雪山,其实比雪山更简单
地面
def land():
jumpTo(-400,0)
t.pencolor('DarkViolet')
t.fillcolor('DarkViolet')
t.begin_fill()
t.goto(-400,-150)
t.seth(0)
t.circle(600,39.5)
t.goto(-400,0)
t.end_fill()
t.pencolor('Plum')
t.fillcolor('Plum')
t.begin_fill()
jumpTo(-400, 0)
t.goto(-400, -150)
t.</