兒童節→python繪製低配版小黃(a_rabbit)肖像畫送給它 ^_^

先上這篇文章的主角吧
gogogo

|
|
|

借用山羊君家小黃圖片

在這裏插入圖片描述

| |

在這裏插入圖片描述


#-*- coding = utf-8 -*-
#@Time : 2020/5/31 21:18
#@Author : Chen
#@File : rabbit_turtle.py
#@Software : PyCharm

import turtle as t

t.screensize(800,600)
t.pensize(2)


# 移動函數封裝
def move(x,y):
    t.speed(290)
    t.pu()
    t.goto(x,y)
    t.pd()

move(0,-30)
t.circle(85)

move(0,10)
t.circle(13)
move(-30,58)
t.circle(16)
move(35,58)
t.circle(16)
move(-30,58)



#眼睛模塊
def ineye():
    t.begin_fill()
    t.color('black')
    t.circle(5)
    t.end_fill()
ineye()
move(35,58)
ineye()

move(1,10)
t.seth(-90)
t.fd(10)
t.circle(10,180)

move(-20,0)
t.seth(270)
t.circle(10,180)


move(-30,-30)
# t.seth(185)
t.pu()
t.circle(130,53)
t.pd()
t.circle(130,262)

move(-153,-120)
t.seth(65)
t.circle(45,160)
t.circle(55,20)
t.seth(0)

# 雙腿部分
move(-153,-120)
t.seth(70)
t.circle(-25,160)
t.seth(0)
t.fd(-30)
# 第二條腿
move(-155,-100)
t.seth(65)
t.pu()
t.circle(55,10)
t.pd()
t.circle(45,140)
move(-150,-100)
t.seth(50)
t.circle(-25,150)

# 手部分

move(-5,-30)
t.fd(90)
move(-20,-120)
t.seth(120)
t.fd(44)
t.seth(-120)
t.fd(44)
t.seth(110)
t.fd(55)

# 尾巴部分:
t.begin_fill()
t.color('black','yellow')
move(-285,-62)
t.circle(20)
t.end_fill()





def radian_left(ang, dis, step, n):
    t.speed(290)

    for i in range(n):
        dis += step  # dis增大step
        t.lt(ang)  # 向左轉ang度
        t.fd(dis)  # 向前走dis的步長
def radian_right(ang, dis, step, n):
    t.speed(290)

    for i in range(n):
        dis += step
        t.rt(ang)  # 向左轉ang度
        t.fd(dis)  # 向前走dis的步長



# 畫耳朵
def ear():
    t.speed(290)
    t.color("black", "white")
    # 左耳朵曲線
    t.pu()  # 提筆
    t.goto(-50, 100)  # 筆頭初始位置
    t.pd()  # 下筆
    t.seth(110)  # 畫筆角度
    t.begin_fill()
    radian_left(1.2, 0.4, 0.1, 40)
    t.seth(270)  # 畫筆角度
    radian_left(1.2, 0.4, 0.1, 40)
    t.seth(44)  # 畫筆角度
    t.fd(32)
    t.end_fill()
    # 右耳朵曲線
    t.pu()  # 提筆
    t.goto(50, 100)  # 筆頭初始位置
    t.pd()  # 下筆
    t.seth(70)  # 畫筆角度
    t.begin_fill()
    radian_right(1.2, 0.4, 0.1, 40)
    t.seth(270)  # 畫筆角度
    radian_right(1.2, 0.4, 0.1, 40)
    t.seth(136)  # 畫筆角度
    t.fd(32)
    t.end_fill()
    # 耳朵黑
    t.begin_fill()
    t.fillcolor("brown")
    t.pu()  # 提筆
    t.goto(88, 141)  # 筆頭初始位置
    t.pd()  # 下筆
    t.seth(35)  # 畫筆角度
    radian_right(1.2, 1.6, 0.1, 16)
    t.seth(270)  # 畫筆角度
    radian_right(1.2, 0.4, 0.1, 25)
    t.seth(132)  # 畫筆角度
    t.fd(31)
    t.end_fill()
    t.begin_fill()
    t.fillcolor("brown")
    t.pu()  # 提筆
    t.goto(-88, 141)  # 筆頭初始位置
    t.pd()  # 下筆
    t.seth(145)  # 畫筆角度
    radian_left(1.2, 1.6, 0.1, 16)
    t.seth(270)  # 畫筆角度
    radian_left(1.2, 0.4, 0.1, 25)
    t.seth(48)  # 畫筆角度
    t.fd(31)
    t.end_fill()
ear()

t.done()

在這裏插入圖片描述


略魔性,技術問題只能將物體→化具體爲抽象
分享

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章