Python画十二生肖(新年版)一

发布时间:2023年12月28日

前言
十二生肖,又叫属相,为中国与十二地支相配以人出生年份的十二种动物,包括鼠、牛、虎、兔、龙、蛇、马、羊、猴、鸡、狗、猪。十二生肖是十二地支的形象化代表,即子(鼠)、丑(牛)、寅(虎)、卯(兔)、辰(龙)、巳(蛇)、午(马)、未(羊)、申(猴)、酉(鸡)、戌(狗)、亥(猪),随着历史的发展逐渐融合到相生相克的民间信仰观念,反映在婚姻、人生、年运等,每一种生肖都有丰富的传说,并以此形成一种观念阐释系统,成为民间文化中的形象哲学,如婚配上的属相、庙会祈祷、本命年等。现代,更多人把生肖作为春节的吉祥物,成为娱乐文化活动的象征。生肖作为悠久的民俗文化符号,历代留下了大量描绘生肖形象和象征意义的诗歌、春联、绘画、书画和民间工艺作品。除中国外,世界多国在春节期间发行生肖邮票,以此来表达对中国新年的祝福。今天,我们来画其中的两个:鼠和牛。

一、福鼠
鼠在十二生肖属于首位,与十二地支中配属,"子",故一天十二时辰中之"子时"--晚上十至凌晨一点,又称"鼠时"。

import turtle as t
t.screensize(300,600)
def ears(dir):  
    t.pu()
    t.goto((0 - dir) * 150, 120)
    t.setheading(0)
    t.pd()
    t.fillcolor('#F2D391')
    t.begin_fill()
    t.circle(80)
    t.end_fill()
    t.pu()
    t.goto((0 - dir) * 120, 120)
    t.setheading(0)
    t.pd()
    t.fillcolor('#F9ECF5')
    t.begin_fill()
    t.circle(60)
    t.end_fill()
def face():
    t.pu()
    t.goto(-45,216)
    t.pd()
    t.color("#FFE4B5","#FFE4B5")
    t.begin_fill()
    t.goto(45,216)
    t.goto(65, -20)
    t.goto(-65, -20)
    t.end_fill()
    t.color("black","#FFE4B5")#底图增加完毕,笔的颜色置回黑色
    #右边脸颊
    t.pu()
    t.goto(65,-20)
    t.pd()
    t.fillcolor('#FFE4B5')
    t.begin_fill()
    t.setheading(10)
    t.circle(120,180)
    #左边脸颊
    t.pu()
    t.goto(-65,-20)
    t.pd()
    t.setheading(170)
    t.circle(-120,180)
    #下巴
    t.pu()
    t.goto(-65,-20)
    t.pd()
    t.goto(65,-20)
    t.end_fill()
def mouth(): # 嘴巴
    #右边嘴巴
    t.pu()
    t.goto(0, 30)
    t.pd()
    t.setheading(-70)
    t.circle(30,180)
    #左边嘴巴
    t.pu()
    t.goto(0, 30)
    t.pd()
    t.setheading(-110)
    t.circle(-30,180)
def eyes(dir):  # 画眼睛,dir用来设置方向,左右眼对称
    #大圈
    t.pu()
    t.goto((0 - dir) * 30, 140)
    t.setheading(90)
    t.pd()
    t.fillcolor('white')
    t.begin_fill()
    t.circle(dir * 30)
    t.end_fill()
    #小圈
    t.pu()
    t.goto((0 - dir) * 40, 135)
    t.setheading(90)
    t.pd()
    t.fillcolor('#AAC9E3')
    t.begin_fill()
    t.circle(dir * 17)
    t.end_fill()
    #小小圈
    t.pu()
    t.goto((0 - dir) * 45, 135)
    t.setheading(90)
    t.pd()
    t.color("white","white")
    t.begin_fill()
    t.circle(dir * 5)
    t.end_fill()
    t.color("black","white")
def nose():  # 画鼻子
    t.pu()
    t.goto(14, 80)
    t.setheading(90)
    t.pd()
    t.fillcolor('red')
    t.begin_fill()
    t.circle(14)
    t.end_fill()
def beard(): #画胡须
    #右边胡须
    t.pu()
    t.goto(90, 80)
    t.pd()
    t.setheading(-15)
    t.fd(150)
    t.pu()
    t.goto(90, 60)
    t.pd()
    t.setheading(-30)
    t.fd(150)
    #左边胡须
    t.pu()
    t.goto(-90, 80)
    t.pd()
    t.setheading(-165)
    t.fd(150)
    t.pu()
    t.goto(-90, 60)
    t.pd()
    t.setheading(-150)
    t.fd(150)
def hat(): #帽子
    #小的半圆
    t.pu()
    t.goto(50, 265)
    t.pd()
    t.setheading(90)
    t.fillcolor('red')
    t.begin_fill()
    t.circle(50,180)
    t.end_fill()
    #大的半圆
    t.fillcolor('red')
    t.begin_fill()
    t.pu()
    t.setheading(0)
    t.goto(-80, 210)
    t.pd()
    t.fd(160)
    t.setheading(90)
    t.circle(80,180)
    t.end_fill()
    #铜钱大圆
    t.fillcolor('yellow')
    t.begin_fill()
    t.pu()
    t.goto(0, 220)
    t.setheading(0)
    t.pd()
    t.circle(30)
    t.end_fill()
    #铜钱小方块
    t.fillcolor('red')
    t.begin_fill()
    t.pu()
    t.goto(-15, 235)
    t.setheading(0)
    t.pd()
    t.fd(30)
    t.lt(90)
    t.fd(30)
    t.lt(90)
    t.fd(30)
    t.lt(90)
    t.fd(30)
    t.end_fill()
def clothes(): #衣服
    #下边衣角
    t.pu()
    t.goto(-120,-168)
    t.pd()
    t.setheading(-90)
    t.fillcolor('red')
    t.begin_fill()
    t.fd(40)
    t.lt(90)
    t.fd(240)
    t.lt(90)
    t.fd(40)
    t.end_fill()
    #加底图
    t.color("red","red")##+42
    t.pu()
    t.goto(-110, -3)
    t.pd()
    t.begin_fill()
    t.goto(-110, -188)
    t.goto(110, -188)
    t.goto(110, -3)
    t.end_fill()
    t.color("black","red")
    #左边袖子
    t.pu()
    t.goto(-110, -3)
    t.pd()
    t.setheading(-150)
    t.begin_fill()
    t.circle(100,160)
    t.setheading(90)
    t.fd(100)
    t.lt(60)
    t.fd(70)
    t.end_fill()
    #右边袖子
    t.pu()
    t.goto(110, -3)
    t.pd()
    t.setheading(-30)
    t.begin_fill()
    t.circle(-100,160)
    t.setheading(90)
    t.fd(100)
    t.rt(60)
    t.fd(70)
    t.end_fill()
    #中间条纹
    t.pu()
    t.goto(-20, -8)
    t.pd()
    t.fillcolor('yellow')
    t.begin_fill()
    t.setheading(-90)
    t.fd(200)
    t.lt(90)
    t.fd(40)
    t.lt(90)
    t.fd(200)
    t.lt(90)
    t.fd(40)
    t.end_fill()
    #袖口条纹
    t.pu()
    t.goto(-43, -188)
    t.pd()
    t.setheading(90)
    t.begin_fill()
    t.fd(100)
    t.lt(60)
    t.fd(40)
    t.setheading(-90)
    t.fd(120)
    t.end_fill()
    t.pu()
    t.goto(43, -188)
    t.pd()
    t.setheading(90)
    t.begin_fill()
    t.fd(100)
    t.rt(60)
    t.fd(40)
    t.setheading(-90)
    t.fd(120)
    t.end_fill()
def hand(): #手
    #左手
    t.pu()
    t.goto(-43, -168)
    t.pd()
    t.setheading(0)
    t.fillcolor('#FFE4B5')
    t.begin_fill()
    t.circle(40,180)
    t.end_fill()
    #左手手指条纹
    t.pu()
    t.goto(-5, -118)
    t.pd()
    t.fd(28)
    t.pu()
    t.goto(-3, -128)
    t.pd()
    t.fd(30)
    t.pu()
    t.goto(-5, -138)
    t.pd()
    t.fd(28)
    #右手
    t.pu()
    t.goto(43, -88)
    t.pd()
    t.setheading(180)
    t.begin_fill()
    t.circle(40,180)
    t.end_fill()
    #右手手指条纹
    t.pu()
    t.goto(5, -118)
    t.pd()
    t.fd(28)
    t.pu()
    t.goto(3, -128)
    t.pd()
    t.fd(30)
    t.pu()
    t.goto(5, -138)
    t.pd()
    t.fd(28)
def trousers(): #裤子
    #左边裤子
    t.pu()
    t.goto(-110,-208)
    t.pd()
    t.setheading(-100)
    t.fillcolor('red')
    t.begin_fill()
    t.fd(100)
    t.setheading(0)
    t.fd(90)
    t.goto(0,-208)
    #右边裤子
    t.pu()
    t.goto(110,-208)
    t.pd()
    t.setheading(-80)
    t.fd(100)
    t.setheading(180)
    t.fd(90)
    t.goto(0,-208)
    t.end_fill()
def shoes(): #鞋子
    #左边鞋子
    t.pu()
    t.goto(-125,-307)
    t.pd()
    t.setheading(-90)
    t.fillcolor('yellow')
    t.begin_fill()
    t.circle(40,180)
    t.end_fill()
    #左边鞋子条纹
    t.pu()
    t.goto(-85,-347)
    t.pd()
    t.setheading(90)
    t.fd(30)
    #右边鞋子
    t.pu()
    t.goto(125,-307)
    t.pd()
    t.setheading(-90)
    t.begin_fill()
    t.circle(-40,180)
    t.end_fill()
    #右边鞋子条纹
    t.pu()
    t.goto(85,-347)
    t.pd()
    t.setheading(90)
    t.fd(30)
t.pensize(2)
clothes()
hand()
trousers()
shoes()
ears(1)
ears(-1)
face()
mouth()
eyes(1)
eyes(-1)
nose()
beard()
hat()
Originator()
t.done()
 

?二、金牛

生肖牛,指的是十二生肖之一的牛。牛在十二生肖中居次位,与十二地支配属"丑",故一天十二时辰中的"丑时"--夜间一点至三点又"牛时"。易卦为"坤为子母牛"。

from turtle import *
import time
 
 
BG_COLOR = '#B30016'
COW_COLOR = 'yellow'
 
 
def draw_circle(radius, color):
    penup()
    setheading(towards(0, 0))
    right(90)
    pencolor(color)
    pendown()
    begin_fill()
    circle(radius)
    fillcolor(color)
    end_fill()
 
 
def draw_circle_and_set_start(radius, color):
    penup()
    sety(-radius)
    setx(0)
    setheading(towards(0, 0))
    right(90)
    pencolor(color)
    pendown()
    begin_fill()
    circle(radius)
    fillcolor(color)
    end_fill()
 
 
def draw_arc(radius, arc, color):
    penup()
    sety(-radius)
    pencolor(color)
    pendown()
    begin_fill()
    circle(radius, extent=arc)
    fillcolor(color)
    end_fill()
 
 
def draw_outer_ring():
    """环形外圈"""
    penup()
    sety(-241)
    setx(0)
    setheading(towards(0, 0))
    right(90)
    circle(240, extent=6)
    pencolor(COW_COLOR)
    pendown()
    begin_fill()
    for i in range(26):
        circle(240, extent=(360-19.5)/26)
        setheading(towards(0, 0))
        forward(24)
        left(90)
        circle(-216, extent=(360-156)/26/2)
        setheading(towards(0, 0))
        forward(7)
        right(90)
        circle(209, extent=(360-136.5)/26)
        setheading(towards(0, 0))
        backward(7)
        left(90)
        circle(-216, extent=(360-156)/26/2)
        setheading(towards(0, 0))
        backward(24)
        right(90)
    fillcolor(COW_COLOR)
    end_fill()
 
 
def draw_inner_ring():
    """环形内圈"""
    penup()
    sety(-232)
    setx(0)
    setheading(towards(0, 0))
    right(90)
    circle(240, extent=5.5)
    pencolor(BG_COLOR)
    circle(232, extent=2)
    pendown()
    begin_fill()
    for i in range(26):
        circle(232, extent=(360-123.5)/26)
        setheading(towards(0, 0))
        forward(8)
        left(90)
        circle(-224, extent=(360-156)/26/2)
        setheading(towards(0, 0))
        forward(23)
        right(90)
        circle(201, extent=(360-32.5)/26)
        setheading(towards(0, 0))
        backward(23)
        left(90)
        circle(-224, extent=(360-156)/26/2)
        setheading(towards(0, 0))
        backward(8)
        right(90)
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_blossom(long):
    color('yellow')
    begin_fill()
    for i in range(40):
        forward(long)
        left(175)
        forward(long)
        right(165)
    fillcolor(COW_COLOR)
    end_fill()
 
 
def draw_flower(a, color):
    pencolor('red')
    begin_fill()
    for j in range(5):
        for i in range(40):
            if 0 <= i < 20:
                a = a - 0.08
            else:
                a = a + 0.08
            forward(a)
            left(6)
        right(168)
    fillcolor(color)
    end_fill()
 
 
def draw_outline_out():
    """外围轮廓"""
    penup()
    sety(-185)
    setx(0)
    setheading(towards(0, 0))
    right(90)
    pendown()
    pencolor(BG_COLOR)
    begin_fill()
    circle(185, extent=130)
    # 绘制尾巴外围
    right(60)
    for i in range(5):
        forward(2.5)
        left(8)
    forward(35)
    left(30)
    a = 5
    for i in range(4):
        forward(a)
        left(38)
        a += 3
    setheading(towards(0, 0))
    right(90)
    circle(185, extent=72)
    right(90)
    circle(-60, extent=65)
    left(30)
    for i in range(4):
        forward(3)
        left(30)
    circle(80, extent=90)
    setheading(towards(0, 0))
    right(90)
    circle(185, extent=6)
    right(45)
    a = 15
    for i in range(9):
        if 0 <= i < 5:
            a = a - 2.5
        else:
            a = a + 2.5
        forward(a)
        left(15)
    setheading(towards(0, 0))
    right(90)
    circle(185, extent=100)
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_outline_inner():
    """牛轮廓"""
    penup()
    sety(-175)
    setx(0)
    setheading(towards(0, 0))
    right(90)
    circle(175, extent=285)
    pendown()
    pencolor(COW_COLOR)
    begin_fill()
    circle(175, extent=155)
    draw_tail()
    draw_body()
    draw_face()
    draw_right_ear()
    draw_right_horn()
    draw_head_up()
    draw_left_horn()
    right(145)
    draw_left_ear()
    fillcolor(COW_COLOR)
    end_fill()
 
 
def draw_face():
    """面部"""
    right(160)
    for i in range(3):
        forward(11)
        left(7)
    left(12)
    forward(43)
    left(30)
    for i in range(3):
        forward(4)
        left(12)
    left(90)
    forward(2)
    left(28)
    for i in range(5):
        forward(9)
        right(4)
    for i in range(3):
        forward(3)
        right(30)
    right(90)
    for i in range(6):
        forward(9.3)
        left(4)
    left(55)
    for i in range(5):
        forward(4.5)
        left(3)
    left(45)
    a = 3.5
    for i in range(5):
        forward(a)
        left(30)
        a += 1
    right(90)
    forward(3)
    right(45)
    a, b = 12, 20
    for i in range(6):
        forward(a)
        left(b)
        a -= 1.5
        b += 10
    right(45)
    forward(3)
    right(45)
    for i in range(5):
        forward(2)
        right(35)
    a = 8
    for i in range(5):
        forward(a)
        right(30)
        a -= 0.9
    left(120)
    a = 6
    for i in range(5):
        forward(a)
        if i < 3:
            left(5)
            a += 2
        else:
            right(5)
            a -= 2
    right(170)
    a = 9
    for i in range(5):
        forward(a)
        # right(5)
        if i < 2:
            left(5)
            a += 2
        else:
            right(10)
            a -= 3
    left(70)
    for i in range(3):
        forward(3)
        right(5)
    for i in range(4):
        forward(5)
        left(8)
    for i in range(6):
        forward(3)
        right(8)
    left(145)
    for i in range(4):
        forward(8)
        left(5)
    for i in range(4):
        forward(3)
        right(10)
    forward(20)
    right(160)
    for i in range(4):
        forward(5)
        right(5)
 
 
def draw_body():
    """身体"""
    right(90)
    a = 24
    for i in range(5):
        forward(a)
        left(7.5)
        a -= 1
    left(60)
    a = 12
    for i in range(5):
        forward(a)
        right(15)
        a -= 1.5
    for i in range(5):
        forward(10)
        right(3)
    right(25)
    for i in range(3):
        forward(12)
        right(7)
 
 
def draw_tail():
    """牛尾"""
    left(8)
    a = 23
    for i in range(10):
        forward(a)
        left(5.8)
        a -= 1.8
    right(90)
    for i in range(4):
        forward(6)
        left(14)
    forward(20)
    for i in range(5):
        forward(1.5)
        right(10)
    left(90)
    forward(2)
    left(45)
    for i in range(2):
        forward(2)
        left(23)
    a, b = 13.5, 0
    for i in range(6):
        forward(a)
        left(b)
        a -= 1.3
        b += 10
    right(70)
    left(8)
    a = 5
    for i in range(10):
        forward(a)
        right(7.8)
        a += 2.3
 
 
def draw_head_up():
    """头顶"""
    forward(20)
    right(30)
    for i in range(6):
        forward(5)
        left(10)
    for i in range(3):
        forward(1)
        right(15)
    a = 5
    for i in range(6):
        forward(a)
        left(10)
        a += 1
    for i in range(7):
        forward(2)
        right(8)
 
 
def draw_right_horn():
    """右牛角"""
    right(100)
    a = 5
    for i in range(10):
        forward(12.5)
        left(a)
        a += 2
    for i in range(3):
        forward(1.5)
        left(43)
    for i in range(4):
        forward(3.2)
        right(4)
    left(100)
    draw_tooth_right(3, 150)
    left(30)
    for i in range(4):
        forward(3.5)
        right(4)
    left(110)
    draw_tooth_right(4, 150)
    left(25)
    for i in range(4):
        forward(3)
        right(4)
    left(110)
    draw_tooth_right(5, 150)
    left(40)
    for i in range(4):
        forward(3.2)
        right(4)
    left(100)
    draw_tooth_right(5, 150)
    left(40)
 
 
def draw_left_horn():
    """左牛角"""
    left(70)
    draw_tooth_left(5.5, 155)
    left(110)
    for i in range(4):
        forward(5.5)
        right(4)
    left(65)
    draw_tooth_left(5, 160)
    left(110)
    for i in range(4):
        forward(4)
        right(4)
    left(70)
    draw_tooth_left(4.5, 160)
    left(118)
    for i in range(4):
        forward(3.5)
        right(4)
    left(60)
    draw_tooth_left(4, 165)
    left(125)
    for i in range(6):
        forward(7.5)
        right(5)
    for i in range(4):
        forward(0.5)
        left(38)
    a, b = 8, 8
    for i in range(13):
        forward(a)
        left(b)
        a += 1
        b += 0.3
 
 
def draw_right_ear():
    """右牛耳"""
    left(70)
    a, b = 12, 15
    for i in range(3):
        forward(a)
        left(b)
        a -= 2
        b += 5
    a = 5
    for i in range(5):
        forward(a)
        left(5)
        a += 1
    for i in range(4):
        left(30)
        forward(2)
    for i in range(5):
        forward(5)
        right(5)
    for i in range(5):
        forward(5.5)
        left(5)
    right(80)
    forward(5)
 
 
def draw_left_ear():
    """左牛耳"""
    for i in range(7):
        forward(4.5)
        right(8.2)
    a = 10
    for i in range(8):
        forward(a)
        left(11)
        if i < 5:
            a -= 1
        else:
            a += 1.5
    for i in range(3):
        forward(2.5)
        left(20)
    a = 10
    for i in range(2):
        forward(a)
        left(12)
        a -= 0.5
    forward(15)
    for i in range(11):
        left(6.5)
        forward(5)
    right(95)
    forward(8)
    right(80)
    a = 8
    for i in range(6):
        forward(a)
        right(5)
        a -= 1
    left(50)
    for i in range(7):
        forward(9)
        left(5)
 
 
def draw_tooth_right(lenght, angle):
    for i in range(5):
        forward(lenght)
        right(10)
    right(angle)
    for i in range(5):
        forward(lenght)
        left(10)
 
 
def draw_tooth_left(lenght, angle):
    for i in range(5):
        forward(lenght)
        left(10)
    right(angle)
    for i in range(5):
        forward(lenght+0.5)
        right(15)
 
 
def draw_tail_inner():
    """尾巴内部"""
    penup()
    goto(118, 105)
    pendown()
    pencolor(BG_COLOR)
    begin_fill()
    setheading(towards(0, 0))
    right(75)
    for i in range(5):
        forward(6)
        right(25)
    right(130)
    for i in range(5):
        forward(3.5)
        left(15)
    left(110)
    forward(12)
    right(150)
    for i in range(5):
        forward(2.5)
        right(5)
    for i in range(4):
        forward(2.5)
        left(5)
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_right_first_flower():
    penup()
    goto(85, -88)
    pendown()
    pencolor(BG_COLOR)
    setheading(towards(0, 0))
    left(40)
    draw_flower(2.2, BG_COLOR)
    penup()
    goto(90, -88)
    pendown()
    draw_blossom(12)
    penup()
    goto(101, -94)
    pendown()
    draw_circle(6, BG_COLOR)
 
 
def draw_right_second_flower():
    penup()
    goto(20, -96)
    pendown()
    pencolor(BG_COLOR)
    setheading(towards(0, 0))
    right(20)
    draw_flower(1.8, BG_COLOR)
    penup()
    goto(20, -100)
    pendown()
    draw_blossom(7)
    penup()
    goto(20, -108)
    pendown()
    draw_circle(4.5, BG_COLOR)
 
 
def draw_left_second_flower():
    penup()
    goto(-30, -115)
    pendown()
    pencolor(BG_COLOR)
    setheading(towards(0, 0))
    right(30)
    draw_flower(2.2, BG_COLOR)
    penup()
    goto(-35, -120)
    pendown()
    draw_blossom(12)
    penup()
    goto(-42, -130)
    pendown()
    draw_circle(6, BG_COLOR)
 
 
def draw_left_first_flower():
    penup()
    goto(-95, -50)
    pendown()
    pencolor(BG_COLOR)
    setheading(towards(0, 0))
    left(8)
    draw_flower(2.3, BG_COLOR)
    penup()
    goto(-102, -55)
    pendown()
    draw_blossom(13)
    penup()
    goto(-113, -62)
    pendown()
    draw_circle(6.5, BG_COLOR)
 
 
def draw_seven_petals():
    pencolor(BG_COLOR)
    penup()
    goto(132, -72)
    pendown()
    setheading(towards(0, 0))
    right(155)
    draw_petal(3.5, 3.5, 1.8, 1.8)
    penup()
    goto(122, -60)
    pendown()
    setheading(towards(0, 0))
    right(120)
    draw_petal(4, 3.5, 1.9, 1.9)
    penup()
    goto(103, -52)
    pendown()
    setheading(towards(0, 0))
    right(100)
    draw_petal(3.6, 3.2, 1.8, 1.8)
    penup()
    goto(84, -53)
    pendown()
    setheading(towards(0, 0))
    right(70)
    draw_petal(3.3, 2.8, 1.5, 1.5)
    penup()
    goto(70, -58)
    pendown()
    setheading(towards(0, 0))
    right(30)
    draw_petal(2.9, 2.5, 1.2, 1.2)
    penup()
    goto(62, -72)
    pendown()
    setheading(towards(0, 0))
    right(10)
    draw_petal(2.8, 2.4, 1.2, 1.2)
    penup()
    goto(60, -85)
    pendown()
    setheading(towards(0, 0))
    left(30)
    draw_petal(2.4, 2.2, 1, 1)
 
 
def draw_petal(a, b,  c, d):
    begin_fill()
    for i in range(9):
        forward(a)
        if i < 5:
            left(18)
            a -= 0.3
        else:
            right(10)
            a += 0.05
    left(120)
    for i in range(9):
        forward(b)
        left(12)
        b -= 0.15
    left(135)
    for i in range(7):
        forward(c)
        right(8)
        c += 0.15
    right(135)
    for i in range(8):
        forward(d)
        if i < 4:
            left(8)
            a -= 0.2
        else:
            right(23)
            a += 0.15
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_water_right():
    pencolor(BG_COLOR)
    penup()
    goto(30, -125)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    right(120)
    a = 7
    for i in range(7):
        forward(a)
        left(10)
        a -= 1
    a = 1
    for i in range(6):
        forward(a)
        right(35)
        a += 0.5
    for i in range(12):
        forward(2.5)
        right(6)
    fillcolor(BG_COLOR)
    end_fill()
    penup()
    goto(25, -145)
    pendown()
    draw_circle(4, BG_COLOR)
 
 
def draw_water_left():
    pencolor(BG_COLOR)
    penup()
    goto(-80, -88)
    pendown()
    draw_circle(4, BG_COLOR)
    penup()
    goto(-115, -30)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    left(120)
    a = 7.2
    for i in range(7):
        forward(a)
        left(10)
        a -= 1
    a = 1
    for i in range(6):
        forward(a)
        right(35)
        a += 0.5
    for i in range(12):
        forward(2.5)
        right(5)
    fillcolor(BG_COLOR)
    end_fill()
    penup()
    goto(-110, -28)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    left(55)
    a = 6.5
    for i in range(6):
        forward(a)
        right(10)
        a -= 1
    a = 1
    for i in range(6):
        forward(a)
        left(35)
        a += 0.4
    for i in range(12):
        forward(2.5)
        left(5)
    fillcolor(BG_COLOR)
    end_fill()
    penup()
    goto(-125, -3)
    pendown()
    draw_circle(4, BG_COLOR)
 
 
def draw_left_ear_inner():
    pencolor(BG_COLOR)
    penup()
    goto(-117, 51)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    right(150)
    a = 8
    for i in range(10):
        forward(a)
        a -= 0.5
        right(5)
    left(150)
    for i in range(12):
        forward(5.8)
        left(9)
    left(150)
    for i in range(5):
        forward(3)
        right(5)
    right(160)
    for i in range(5):
        forward(3.1)
        left(5)
    left(160)
    for i in range(5):
        forward(6)
        right(6)
    right(160)
    for i in range(5):
        forward(6)
        left(7.5)
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_head_up_flower():
    pencolor(BG_COLOR)
    penup()
    goto(-28, 102)
    pendown()
    setheading(towards(0, 0))
    right(128)
    begin_fill()
    a = 1.7
    for j in range(3):
        for i in range(40):
            if 0 <= i < 20:
                a = a - 0.07
            else:
                a = a + 0.07
            forward(a)
            left(6)
        right(168)
    fillcolor(BG_COLOR)
    end_fill()
    pencolor(COW_COLOR)
    penup()
    goto(-37, 102)
    pendown()
    setheading(towards(0, 0))
    right(85)
    draw_little_moon()
    penup()
    goto(-29, 83)
    pendown()
    setheading(towards(0, 0))
    right(5)
    draw_little_moon()
    penup()
    goto(-10, 88)
    pendown()
    setheading(towards(0, 0))
    left(65)
    draw_little_moon()
    penup()
    goto(-23, 99)
    pendown()
    draw_blossom(6.5)
 
 
def draw_little_moon():
    begin_fill()
    for i in range(10):
        forward(1.1)
        left(15)
    right(170)
    for i in range(10):
        forward(1.2)
        right(20)
    fillcolor(COW_COLOR)
    end_fill()
 
 
def draw_right_ear_inner():
    pencolor(BG_COLOR)
    penup()
    goto(31, 37)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    left(106)
    a = 6
    for i in range(10):
        forward(a)
        a -= 0.5
        left(5)
    right(140)
    for i in range(10):
        forward(4)
        right(11)
    right(135)
    for i in range(3):
        forward(2)
        left(5)
    left(140)
    for i in range(3):
        forward(3)
        right(5)
    right(150)
    for i in range(5):
        forward(4)
        left(6)
    left(155)
    for i in range(5):
        forward(4.5)
        right(7)
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_nose():
    pencolor(BG_COLOR)
    penup()
    goto(30, -29)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    left(170)
    forward(4)
    for i in range(3):
        forward(1)
        left(48)
    forward(3.5)
    for i in range(8):
        forward(1)
        left(20)
    fillcolor(BG_COLOR)
    end_fill()
    penup()
    goto(5, -28)
    begin_fill()
    pendown()
    setheading(towards(0, 0))
    left(95)
    for i in range(5):
        forward(2.5)
        left(2)
    a = 0.5
    for i in range(8):
        forward(a)
        right(35)
        a += 0.8
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_water_up():
    pencolor(BG_COLOR)
    penup()
    goto(-92, 18)
    pendown()
    setheading(towards(0, 0))
    right(18)
    begin_fill()
    a = 7
    for i in range(6):
        forward(a)
        right(18)
        a -= 1
    a = 1
    for i in range(6):
        forward(a)
        left(35)
        a += 0.25
    for i in range(12):
        forward(2.5)
        left(9)
    fillcolor(BG_COLOR)
    end_fill()
    penup()
    goto(-95, 25)
    pendown()
    setheading(towards(0, 0))
    left(10)
    begin_fill()
    for i in range(10):
        forward(6)
        right(8)
    left(180)
    for i in range(10):
        forward(7)
        left(10.8)
    fillcolor(BG_COLOR)
    end_fill()
 
 
def draw_five_circle():
    pencolor(BG_COLOR)
    penup()
    goto(-42, -36)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(4.8, BG_COLOR)
    pencolor(BG_COLOR)
    penup()
    goto(-40, -22)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(3.8, BG_COLOR)
    penup()
    goto(-42, -10)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(3, BG_COLOR)
    penup()
    goto(-44, 0)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(2.5, BG_COLOR)
    penup()
    goto(-49, 7)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(2, BG_COLOR)
 
 
def draw_eye():
    pencolor(BG_COLOR)
    penup()
    goto(-75, 40)
    pendown()
    setheading(towards(0, 0))
    right(38)
    begin_fill()
    a = 3.5
    for i in range(7):
        forward(a)
        left(15)
        a += 0.5
    left(70)
    a = 7
    for i in range(7):
        forward(a)
        left(18)
        a -= 0.5
    left(150)
    a = 3
    for i in range(7):
        forward(a)
        right(14)
        a += 0.5
    right(80)
    a = 6.5
    for i in range(5):
        forward(a)
        right(16)
        a -= 0.5
    fillcolor(BG_COLOR)
    end_fill()
    penup()
    goto(-68, 44)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(7, BG_COLOR)
    penup()
    goto(-64, 42)
    pendown()
    setheading(towards(0, 0))
    right(90)
    draw_circle(4, COW_COLOR)
 
 
def draw_eyelash():
    pencolor(BG_COLOR)
    penup()
    goto(-40, 32)
    pendown()
    setheading(towards(0, 0))
    left(10)
    draw_petal(1.8, 1.6, 0.6, 0.6)
    penup()
    goto(-42, 39)
    pendown()
    setheading(towards(0, 0))
    left(30)
    draw_petal(2, 1.8, 0.8, 0.8)
    penup()
    goto(-46, 45)
    pendown()
    setheading(towards(0, 0))
    left(50)
    draw_petal(2.3, 2, 1, 1)
    penup()
    goto(-52, 52)
    pendown()
    setheading(towards(0, 0))
    left(80)
    draw_petal(2.4, 2.1, 1, 1)
    penup()
    goto(-62, 55)
    pendown()
    setheading(towards(0, 0))
    left(90)
    draw_petal(2.5, 2.2, 1.1, 1.1)
    penup()
    goto(-72, 55)
    pendown()
    setheading(towards(0, 0))
    left(115)
    draw_petal(2.4, 2.1, 1, 1)
 
 
if __name__ == '__main__':
    setup(800, 600, 150, 100)
    screensize(1040, 585, BG_COLOR)
    pencolor(COW_COLOR)
    speed(10)
    time.sleep(1)
    draw_circle_and_set_start(255, COW_COLOR)
    draw_circle_and_set_start(245, BG_COLOR)
    draw_outer_ring()
    draw_inner_ring()
    draw_circle_and_set_start(198, COW_COLOR)
    draw_circle_and_set_start(185, BG_COLOR)
    draw_outline_out()
    draw_outline_inner()
    draw_tail_inner()
    draw_right_first_flower()
    draw_seven_petals()
    draw_right_second_flower()
    draw_water_right()
    draw_left_second_flower()
    draw_left_first_flower()
    draw_water_left()
    draw_water_up()
    draw_left_ear_inner()
    draw_head_up_flower()
    draw_right_ear_inner()
    draw_nose()
    draw_five_circle()
    draw_eyelash()
    draw_eye()
    penup()
    goto(400, 0)
    done()
Footer

总结

先做了两个,后续会再更。

文章来源:https://blog.csdn.net/m0_69824302/article/details/135186713
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。