【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

 一、前言

        大家好,我是猿童学🐵,欢迎来到中秋创作第三期,祝大家中秋节快乐。嫦娥相信大家不会陌生,她是中国古代神话中的人物。熟话说:“嫦娥飞天去,神州归来也”,今天使用海龟库给大家画一幅嫦娥奔月图。

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

 嫦娥飞天去,神州归来也

二、效果展示

让大家看看嫦娥小姐姐。🤣🤣🤣

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

中秋·赏月吟

花好月圆时,中秋佳节至,手中白瓷杯,月在杯中醉。

饮一掬月色,话一世浮沉,忽觉眼前人,更胜天上月。

三、代码解析

将代码模块化,使用函数来划分,一个一个的分解,到最后在调用组合,使复杂的问题简单化。

3.1初始化背景,设置窗口大小及背景颜色

def draw_bg():
    t.penup()
    t.goto(-700, -350)
    t.pendown()
    t.color((30, 30, 60), (30, 30, 60))
    t.begin_fill()
    t.goto(700, -350)
    t.goto(700, 350)
    t.goto(-700, 350)
    t.goto(-700, -350)
    t.end_fill()
    t.penup()

def init_draw():
    t.setup(1400, 700, startx=100, starty=100)
    t.colormode(255)
    # 这样设置背景导出的图片看不到背景
    # t.bgcolor(30, 30, 60)
    # 画背景
    draw_bg()

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.2 画星星,随机生成不同颜色的星星

def draw_star(s):
    t.begin_fill()
    for _ in range(6):
        t.forward(s)
        t.right(270)
        t.forward(s)
        t.right(150)
    t.end_fill()

def draw_stars(sn):
    for _ in range(sn):
        t.penup()
        t.goto(r.randint(-500, 600), r.randint(-100, 300))
        t.pendown()
        c = r.choice(('purple', 'green', 'yellow', 'white', 'blue'))
        t.color(c, c)
        t.seth(30)
        draw_star(r.randint(2, 5))

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.3 画假山

def draw_mount(d, a):
    t.penup()
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.pendown()
    t.begin_fill()
    for x in range(-700, 1000):
        t.goto(x-a*d, math.cos(a*(x+699)/d)*d-100*a)
    t.goto(700, -700)
    t.goto(-700, -700)
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.end_fill()

def draw_mounts():
    t.color('#90EE90', '#90EE90')
    draw_mount(80, 1)
    t.color('#87CEEB', '#87CEEB')
    draw_mount(70, 1.75)
    t.color('#7D9EC0', '#7D9EC0')
    draw_mount(60, 2.5)

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.4 画月亮,有不同形状的月亮选择,圆的月亮,弯的月亮。

def draw_moon():
    t.penup()
    # t.goto(-510, 300)
    t.goto(-550, 300)
    t.pendown()
    t.color('yellow', 'yellow')
    t.begin_fill()
    # 弯月
    # t.right(15)
    # t.circle(-60, 220)
    # t.right(140)
    # t.circle(60, 140)
    # 圆月
    t.right(15)
    t.circle(-100)
    t.end_fill()

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.5 画广寒宫

def draw_frool(y, j, w, h):
    # 房框
    t.penup()
    t.goto(y, j)
    t.pendown()
    t.goto(y-w, j)
    t.goto(y-w, j+h)
    t.goto(y, j+h)
    t.goto(y, j)
    # 左房檐
    t.penup()
    t.goto(y-w, j+h)
    t.seth(180)
    t.pendown()
    t.circle(-(int(w/3)), 60)
    # 右房檐
    t.penup()
    t.goto(y, j+h)
    t.seth(0)
    t.pendown()
    t.circle(int(w/3), 60)
    # 房门
    if y==-480:
        t.penup()
        t.goto(y-int(w*0.3), j)
        t.pendown()
        t.goto(y-int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j)
        t.penup()
        t.goto(y-int(w*0.5), j+int(h/2))
        t.pendown()
        t.goto(y-int(w*0.5), j)
        t.penup()
        t.goto(y-int(w*0.42), j+int(h/4))
        t.pendown()
        t.circle(0.5)
        t.penup()
        t.goto(y-int(w*0.58), j+int(h/4))
        t.pendown()
        t.circle(0.5)
    # 画窗户
    else:
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.2))
        t.goto(y-w+int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.5), j+int(h*0.2))
        t.pendown()
        t.goto(y-int(w*0.5), j+h-int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.5))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.5))

def draw_palace():
    t.color('white')
    t.width(4)
    draw_frool(-480, 160, 100, 60)
    draw_frool(-500, 220, 60, 25)
    draw_frool(-510, 245, 40, 20)
    draw_frool(-518, 265, 24, 12)
    draw_frool(-524, 277, 12, 8)
    draw_frool(-528, 285, 4, 2)

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.6 画树

def draw_tree(s, f=5, h=90):
    if f == 0:
        return
    t.pendown()
    t.seth(h)
    t.fd(s+10 if f==5 else s)
    draw_tree(s>>1, f-1, h+45)
    t.penup()
    t.seth(h+45+180); t.fd(s>>1)
    draw_tree(s>>1, f-1, h-45)
    t.penup()
    t.seth(h-45+180); t.fd(s>>1)

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.7 画吴刚

def draw_WuGang():
    t.width(2)
    # 头
    ## 脸
    t.penup()
    t.goto(-472, 162)
    t.seth(70)
    t.pendown()
    t.color('black')
    t.circle(6, 140)
    t.color('#b3c518')
    t.circle(6, 220)
    ## 发髻
    t.penup()
    t.circle(6, 10)
    t.pendown()
    t.color('black')
    t.begin_fill()
    t.circle(-2)
    t.end_fill()
    ## 眼
    t.penup()
    t.goto(-478, 165)
    t.seth(90)
    t.pendown()
    t.fd(2)
    ## 嘴
    t.penup()
    t.goto(-481, 161)
    t.seth(-30)
    t.pendown()
    t.color('pink')
    t.circle(3, 50)
    # 身体
    ## 腰
    t.penup()
    t.color('#386650', '#386650')
    t.goto(-482, 143)
    t.pendown()
    t.seth(-110)
    t.fd(12)
    t.circle(1, 160)
    t.fd(12)
    t.right(120)
    t.fd(12)
    t.circle(1, 160)
    t.fd(14)
    ## 右肩
    t.penup()
    t.color('#5cd29b')
    t.seth(-1)
    t.goto(-475, 158)
    t.pendown()
    t.circle(-6, 90)
    ## 右手
    t.fd(3)
    t.color(skin)
    t.left(149)
    t.fd(1)
    t.circle(-2, 180)
    t.fd(2)
    t.circle(-4, 150)
    t.color('#4cd29b')
    t.fd(3)
    # 身体中插入一个斧子 #
    ###################
    ## 斧子把
    t.penup()
    t.goto(-486, 143)
    t.color('brown')
    t.pendown()
    t.goto(-456, 152)
    ## 斧子头
    t.penup()
    t.width(1)
    t.goto(-458, 148)
    t.color('black', 'black')
    t.pendown()
    t.begin_fill()
    t.seth(190)
    t.fd(1)
    t.right(90)
    t.fd(3)
    t.circle(8, 60)
    t.right(110)
    t.circle(-8, 80)
    t.right(110)
    t.circle(8, 60)
    t.fd(4)
    t.end_fill()
    ###################
    ## 左肩
    t.penup()
    t.width(2)
    t.color('#4cd29b')
    t.seth(180)
    t.goto(-482, 158)
    t.pendown()
    t.circle(5, 90)
    ## 左手
    t.fd(5)
    t.color(skin)
    t.circle(2, 60)
    t.fd(4)
    t.circle(2, 180)
    t.fd(3)
    t.color('#5cd29b')
    t.circle(-1, 60)
    t.fd(3)

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

3.8 画嫦娥姐姐

def draw_ChangE():
    lx, ly = -530, 170
    # 左手
    t.penup()
    t.color(skin)
    t.width(4)
    t.goto(lx, ly)
    t.seth(50)
    t.pendown()
    t.fd(10)
    t.circle(-3, 180)
    t.right(170)
    t.circle(-6, 180)
    t.circle(-50, 20)
    # 左袖
    t.penup()
    t.color('red')
    t.goto(lx, ly)
    t.seth(-140)
    t.pendown()
    t.fd(16)
    t.penup()
    t.goto(lx, ly)
    t.seth(-50)
    t.pendown()
    t.fd(30)
    t.right(90)
    t.fd(10)
    t.circle(-50, 40)
    # 衣服
    t.color('#f3dd64')
    t.penup()
    t.right(90)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-100, 8)
    t.circle(-20, 80)
    t.circle(-100, 11)
    # 衣服2
    t.penup()
    t.circle(-100, -11)
    t.circle(-20, -80)
    t.fd(8)
    t.pendown()
    t.circle(-100, 6)
    t.circle(-15, 82)
    t.circle(-40, 35)
    # 衣服-裙
    t.color('red')
    t.penup()
    t.circle(-40, -35)
    t.circle(-15, -82)
    t.fd(10)
    t.right(10)
    t.pendown()
    t.circle(-100, 60)
    t.right(60)
    t.circle(-100, 60)
    t.right(60)
    t.circle(-200, 2)
    # 右袖
    t.penup()
    t.circle(-200, -2)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-10)
    t.fd(-6)
    t.circle(-100, -6)
    t.fd(-8)
    t.circle(-20, 80)
    t.circle(-100, 12)
    t.right(110)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-50, 50)
    t.right(70)
    t.circle(-50, 40)
    t.right(57)
    t.circle(-200, 10)
    # 右手
    t.penup()
    t.circle(-200, -10)
    t.right(-57)
    t.circle(-50, -4)
    t.color(skin)
    t.left(80)
    t.circle(10, 15)
    t.pendown()
    t.circle(10, 190)
    # 下方飘带
    t.penup()
    t.circle(10, -90)
    t.seth(-140)
    t.color('#f3dd64')
    t.circle(-10, 10)
    t.pendown()
    t.circle(-10, 100)
    t.circle(-40, 20)
    t.circle(40, 70)
    t.left(80)
    t.circle(60, 40)
    t.left(60)
    t.circle(-30, 50)
    t.circle(20, 80)
    t.fd(25)
    # 脸
    t.penup()
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.circle(-30, 100)
    t.color('black')
    t.begin_fill()
    t.circle(-30, 30)
    # 耳朵
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    # 头发
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.circle(3, 160)
    t.circle(25, 90)
    t.left(20)
    t.fd(20)
    t.right(80)
    t.circle(20, 150)
    t.right(80)
    t.circle(8, 180)
    t.right(90)
    t.fd(10)
    t.right(110)
    t.circle(10, 100)
    t.right(110)
    t.fd(12)
    t.circle(8, 110)
    t.right(50)
    t.circle(12, 70)
    t.circle(2, 50)
    t.circle(180, 25)
    t.end_fill()
    # 发髻
    t.penup()
    t.circle(180, -25)
    t.circle(2, -50)
    t.circle(12, -70)
    t.right(-50)
    t.circle(8, -110)
    t.fd(-12)
    t.right(-110)
    t.circle(10, -100)
    t.right(-110)
    t.fd(-10)
    t.right(-90)
    t.circle(8, -180)
    t.fd(-25)
    t.left(20)
    t.color('yellow')
    t.width(1)
    t.pendown()
    t.begin_fill()
    t.fd(8)
    t.right(90)
    t.circle(-4, 180)
    t.end_fill()
    # 脸
    t.penup()
    t.width(1)
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.begin_fill()
    t.circle(-30, 130)
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.left(3)
    t.circle(-200, 9)
    t.end_fill()
    # 眼睛
    t.penup()
    t.width(6)
    t.goto(lx, ly)
    t.color('black')
    t.seth(170)
    t.fd(25)
    t.pendown()
    t.seth(120)
    t.fd(4)
    t.penup()
    t.left(90)
    t.fd(30)
    t.left(90)
    t.pendown()
    t.fd(4)
    # 嘴
    t.penup()
    t.circle(100, 10)
    t.width(4)
    t.left(40)
    t.color('red')
    t.pendown()
    t.circle(100, 3)
    t.circle(15, 90)
    t.circle(100, 3)

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

四、完整代码

import turtle as t
import time
import random as r 
import math
skin = '#ffffeb'

def draw_bg():
    t.penup()
    t.goto(-700, -350)
    t.pendown()
    t.color((30, 30, 60), (30, 30, 60))
    t.begin_fill()
    t.goto(700, -350)
    t.goto(700, 350)
    t.goto(-700, 350)
    t.goto(-700, -350)
    t.end_fill()
    t.penup()

def init_draw():
    t.setup(1400, 700, startx=100, starty=100)
    t.colormode(255)
    # 这样设置背景导出的图片看不到背景
    # t.bgcolor(30, 30, 60)
    # 画背景
    draw_bg()

def draw_moon():
    t.penup()
    # t.goto(-510, 300)
    t.goto(-550, 300)
    t.pendown()
    t.color('yellow', 'yellow')
    t.begin_fill()
    # 弯月
    # t.right(15)
    # t.circle(-60, 220)
    # t.right(140)
    # t.circle(60, 140)
    # 圆月
    t.right(15)
    t.circle(-100)
    t.end_fill()

def draw_star(s):
    t.begin_fill()
    for _ in range(6):
        t.forward(s)
        t.right(270)
        t.forward(s)
        t.right(150)
    t.end_fill()

def draw_stars(sn):
    for _ in range(sn):
        t.penup()
        t.goto(r.randint(-500, 600), r.randint(-100, 300))
        t.pendown()
        c = r.choice(('purple', 'green', 'yellow', 'white', 'blue'))
        t.color(c, c)
        t.seth(30)
        draw_star(r.randint(2, 5))

def draw_mount(d, a):
    t.penup()
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.pendown()
    t.begin_fill()
    for x in range(-700, 1000):
        t.goto(x-a*d, math.cos(a*(x+699)/d)*d-100*a)
    t.goto(700, -700)
    t.goto(-700, -700)
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.end_fill()

def draw_mounts():
    t.color('#90EE90', '#90EE90')
    draw_mount(80, 1)
    t.color('#87CEEB', '#87CEEB')
    draw_mount(70, 1.75)
    t.color('#7D9EC0', '#7D9EC0')
    draw_mount(60, 2.5)

def draw_tree(s, f=5, h=90):
    if f == 0:
        return
    t.pendown()
    t.seth(h)
    t.fd(s+10 if f==5 else s)
    draw_tree(s>>1, f-1, h+45)
    t.penup()
    t.seth(h+45+180); t.fd(s>>1)
    draw_tree(s>>1, f-1, h-45)
    t.penup()
    t.seth(h-45+180); t.fd(s>>1)

def draw_WuGang():
    t.width(2)
    # 头
    ## 脸
    t.penup()
    t.goto(-472, 162)
    t.seth(70)
    t.pendown()
    t.color('black')
    t.circle(6, 140)
    t.color('#b3c518')
    t.circle(6, 220)
    ## 发髻
    t.penup()
    t.circle(6, 10)
    t.pendown()
    t.color('black')
    t.begin_fill()
    t.circle(-2)
    t.end_fill()
    ## 眼
    t.penup()
    t.goto(-478, 165)
    t.seth(90)
    t.pendown()
    t.fd(2)
    ## 嘴
    t.penup()
    t.goto(-481, 161)
    t.seth(-30)
    t.pendown()
    t.color('pink')
    t.circle(3, 50)
    # 身体
    ## 腰
    t.penup()
    t.color('#386650', '#386650')
    t.goto(-482, 143)
    t.pendown()
    t.seth(-110)
    t.fd(12)
    t.circle(1, 160)
    t.fd(12)
    t.right(120)
    t.fd(12)
    t.circle(1, 160)
    t.fd(14)
    ## 右肩
    t.penup()
    t.color('#5cd29b')
    t.seth(-1)
    t.goto(-475, 158)
    t.pendown()
    t.circle(-6, 90)
    ## 右手
    t.fd(3)
    t.color(skin)
    t.left(149)
    t.fd(1)
    t.circle(-2, 180)
    t.fd(2)
    t.circle(-4, 150)
    t.color('#4cd29b')
    t.fd(3)
    # 身体中插入一个斧子 #
    ###################
    ## 斧子把
    t.penup()
    t.goto(-486, 143)
    t.color('brown')
    t.pendown()
    t.goto(-456, 152)
    ## 斧子头
    t.penup()
    t.width(1)
    t.goto(-458, 148)
    t.color('black', 'black')
    t.pendown()
    t.begin_fill()
    t.seth(190)
    t.fd(1)
    t.right(90)
    t.fd(3)
    t.circle(8, 60)
    t.right(110)
    t.circle(-8, 80)
    t.right(110)
    t.circle(8, 60)
    t.fd(4)
    t.end_fill()
    ###################
    ## 左肩
    t.penup()
    t.width(2)
    t.color('#4cd29b')
    t.seth(180)
    t.goto(-482, 158)
    t.pendown()
    t.circle(5, 90)
    ## 左手
    t.fd(5)
    t.color(skin)
    t.circle(2, 60)
    t.fd(4)
    t.circle(2, 180)
    t.fd(3)
    t.color('#5cd29b')
    t.circle(-1, 60)
    t.fd(3)

def draw_frool(y, j, w, h):
    # 房框
    t.penup()
    t.goto(y, j)
    t.pendown()
    t.goto(y-w, j)
    t.goto(y-w, j+h)
    t.goto(y, j+h)
    t.goto(y, j)
    # 左房檐
    t.penup()
    t.goto(y-w, j+h)
    t.seth(180)
    t.pendown()
    t.circle(-(int(w/3)), 60)
    # 右房檐
    t.penup()
    t.goto(y, j+h)
    t.seth(0)
    t.pendown()
    t.circle(int(w/3), 60)
    # 房门
    if y==-480:
        t.penup()
        t.goto(y-int(w*0.3), j)
        t.pendown()
        t.goto(y-int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j)
        t.penup()
        t.goto(y-int(w*0.5), j+int(h/2))
        t.pendown()
        t.goto(y-int(w*0.5), j)
        t.penup()
        t.goto(y-int(w*0.42), j+int(h/4))
        t.pendown()
        t.circle(0.5)
        t.penup()
        t.goto(y-int(w*0.58), j+int(h/4))
        t.pendown()
        t.circle(0.5)
    # 画窗户
    else:
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.2))
        t.goto(y-w+int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.5), j+int(h*0.2))
        t.pendown()
        t.goto(y-int(w*0.5), j+h-int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.5))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.5))

def draw_palace():
    t.color('white')
    t.width(4)
    draw_frool(-480, 160, 100, 60)
    draw_frool(-500, 220, 60, 25)
    draw_frool(-510, 245, 40, 20)
    draw_frool(-518, 265, 24, 12)
    draw_frool(-524, 277, 12, 8)
    draw_frool(-528, 285, 4, 2)

def draw_ChangE():
    lx, ly = -530, 170
    # 左手
    t.penup()
    t.color(skin)
    t.width(4)
    t.goto(lx, ly)
    t.seth(50)
    t.pendown()
    t.fd(10)
    t.circle(-3, 180)
    t.right(170)
    t.circle(-6, 180)
    t.circle(-50, 20)
    # 左袖
    t.penup()
    t.color('red')
    t.goto(lx, ly)
    t.seth(-140)
    t.pendown()
    t.fd(16)
    t.penup()
    t.goto(lx, ly)
    t.seth(-50)
    t.pendown()
    t.fd(30)
    t.right(90)
    t.fd(10)
    t.circle(-50, 40)
    # 衣服
    t.color('#f3dd64')
    t.penup()
    t.right(90)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-100, 8)
    t.circle(-20, 80)
    t.circle(-100, 11)
    # 衣服2
    t.penup()
    t.circle(-100, -11)
    t.circle(-20, -80)
    t.fd(8)
    t.pendown()
    t.circle(-100, 6)
    t.circle(-15, 82)
    t.circle(-40, 35)
    # 衣服-裙
    t.color('red')
    t.penup()
    t.circle(-40, -35)
    t.circle(-15, -82)
    t.fd(10)
    t.right(10)
    t.pendown()
    t.circle(-100, 60)
    t.right(60)
    t.circle(-100, 60)
    t.right(60)
    t.circle(-200, 2)
    # 右袖
    t.penup()
    t.circle(-200, -2)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-10)
    t.fd(-6)
    t.circle(-100, -6)
    t.fd(-8)
    t.circle(-20, 80)
    t.circle(-100, 12)
    t.right(110)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-50, 50)
    t.right(70)
    t.circle(-50, 40)
    t.right(57)
    t.circle(-200, 10)
    # 右手
    t.penup()
    t.circle(-200, -10)
    t.right(-57)
    t.circle(-50, -4)
    t.color(skin)
    t.left(80)
    t.circle(10, 15)
    t.pendown()
    t.circle(10, 190)
    # 下方飘带
    t.penup()
    t.circle(10, -90)
    t.seth(-140)
    t.color('#f3dd64')
    t.circle(-10, 10)
    t.pendown()
    t.circle(-10, 100)
    t.circle(-40, 20)
    t.circle(40, 70)
    t.left(80)
    t.circle(60, 40)
    t.left(60)
    t.circle(-30, 50)
    t.circle(20, 80)
    t.fd(25)
    # 脸
    t.penup()
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.circle(-30, 100)
    t.color('black')
    t.begin_fill()
    t.circle(-30, 30)
    # 耳朵
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    # 头发
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.circle(3, 160)
    t.circle(25, 90)
    t.left(20)
    t.fd(20)
    t.right(80)
    t.circle(20, 150)
    t.right(80)
    t.circle(8, 180)
    t.right(90)
    t.fd(10)
    t.right(110)
    t.circle(10, 100)
    t.right(110)
    t.fd(12)
    t.circle(8, 110)
    t.right(50)
    t.circle(12, 70)
    t.circle(2, 50)
    t.circle(180, 25)
    t.end_fill()
    # 发髻
    t.penup()
    t.circle(180, -25)
    t.circle(2, -50)
    t.circle(12, -70)
    t.right(-50)
    t.circle(8, -110)
    t.fd(-12)
    t.right(-110)
    t.circle(10, -100)
    t.right(-110)
    t.fd(-10)
    t.right(-90)
    t.circle(8, -180)
    t.fd(-25)
    t.left(20)
    t.color('yellow')
    t.width(1)
    t.pendown()
    t.begin_fill()
    t.fd(8)
    t.right(90)
    t.circle(-4, 180)
    t.end_fill()
    # 脸
    t.penup()
    t.width(1)
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.begin_fill()
    t.circle(-30, 130)
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.left(3)
    t.circle(-200, 9)
    t.end_fill()
    # 眼睛
    t.penup()
    t.width(6)
    t.goto(lx, ly)
    t.color('black')
    t.seth(170)
    t.fd(25)
    t.pendown()
    t.seth(120)
    t.fd(4)
    t.penup()
    t.left(90)
    t.fd(30)
    t.left(90)
    t.pendown()
    t.fd(4)
    # 嘴
    t.penup()
    t.circle(100, 10)
    t.width(4)
    t.left(40)
    t.color('red')
    t.pendown()
    t.circle(100, 3)
    t.circle(15, 90)
    t.circle(100, 3)

def add_moon_palace():
    # 画月宫
    draw_palace()
    # 画树
    t.penup()
    t.color('brown')
    t.goto(-500, 110)
    t.width(3)
    draw_tree(80)
    # 画吴刚
    draw_WuGang()
    # 画嫦娥
    draw_ChangE()

def save_draw():
    ts = t.getscreen()
    ts.getcanvas().postscript(file='o.eps')

if __name__ == '__main__':
    t.speed(100)
    init_draw()
    t.speed(10)
    t.speed(40)
    draw_stars(30)
    t.speed(100)
    draw_mounts()
    t.speed(10)
    draw_moon()
    t.speed(100)
    add_moon_palace()
    t.penup()
    t.speed(100)
    t.goto(0, -700)
    save_draw()
    time.sleep(9)
    t.mainloop()

五、结束语 

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

大家多多支持,创作不易,祝大家中秋快乐!

希望明年的中秋,初心不变!加油!

 往期:

【中秋征文】使用Python中秋节创意图画月饼《花好月圆》

【中秋征文】使用Python中秋节嫦娥投食游戏《千里婵娟》

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年3月6日
下一篇 2023年3月6日

相关推荐