聽說CSDN裏的人都是繪圖的好手,那麼有種接受挑戰嘛,和我一起繪製全網各態皮卡丘!
最近爬蟲遇到瓶頸,於是找了幾張圖皮卡丘的圖繪製一下,勉勉強強,還看得的下去,所以滋生了一個繪圖比賽,本篇博客講訴大致模塊方法, 如果你們看完,能畫出更好的皮卡丘,歡迎在評論區告訴我,有獎活動喲! 尋找最萌皮卡丘活動正在開始!
其實我腦子是想畫的上面這張皮卡丘圖片,結果,我的手做出了相反的決定,如下: 不堪入目------ 我也不知道在我手裏就成了這個呆萌樣,憨憨一樣的,
準備工作:
- 預先使用紙和筆大致勾勒出輪廓, 以屏幕中心爲原點,建立座標系,估算五官的幾個重要的座標點,記錄下來。
- 使用函數庫: turtle
- 使用大腦和手 開始繪製:
代碼如下:
# -*- coding : utf-8 -*-
# @Time : 2020/6/7 17:24
# @author : 沙漏在下雨
# @Software : PyCharm
# @CSDN : https://me.csdn.net/qq_45906219
import turtle as T
class Draw:
def __init__(self):
"""
初始化實例
"""
self.t = T.Turtle()
self.w = T.Screen()
self.t.getscreen().tracer(5, 0)
# self.w.exitonclick()
self.t.pensize(2)
self.t.hideturtle()
self.w.screensize(bg='yellow')
def draw_sun(self, x, y, color):
self.t.penup()
self.t.goto(x, y)
self.t.pendown()
self.t.begin_fill()
self.t.fillcolor(color)
self.t.circle(80)
self.t.end_fill()
def draw_eye(self, location):
"""
繪製眼睛 和 眉毛
params : location 座標
"""
self.t.penup()
self.t.goto(location[0], location[1])
self.t.pendown()
self.t.color((0, 0, 0), (0, 0, 0))
self.t.begin_fill()
self.t.circle(location[4])
self.t.end_fill()
self.t.penup()
self.t.goto(location[2], location[3])
self.t.pendown()
self.t.begin_fill()
self.t.color('white', 'white')
self.t.circle(location[5])
self.t.end_fill()
# 開始繪製眉毛
self.t.penup()
eyebrow_x, eyebrow_y = location[0] - 70, location[1] + 120
self.t.goto(eyebrow_x, eyebrow_y)
self.t.pendown()
self.t.pensize(10)
self.t.pencolor('black')
self.t.circle(location[6], location[7])
def red_round(self, location):
"""
繪製左右紅暈
"""
self.t.pensize(2)
self.t.penup()
self.t.goto(location[0], location[1])
self.t.pendown()
self.t.color('gold', 'red')
self.t.begin_fill()
self.t.circle(60)
self.t.end_fill()
def draw_nose(self, location):
"""
繪製鼻子
"""
self.t.penup()
self.t.goto(location[0], location[1])
self.t.pendown()
self.t.pensize(0.1)
self.t.color('black', 'black')
self.t.left(30)
self.t.begin_fill()
for i in range(100):
self.t.right(1)
self.t.fd(0.8)
self.t.end_fill()
def draw_outward(self, location):
"""
繪製輪廓
"""
self.t.penup()
self.t.goto(location[0], location[1])
self.t.pendown()
self.t.pensize(4)
self.t.pencolor('Tan')
self.t.circle(500, 140)
def time_draw(self):
"""
調度函數, 在此調用其他函數的執行
"""
# self.t.pencolor('gold')
# self.draw_sun(200, 200, 'red')
# 繪製皮卡丘左眼
self.draw_eye(location=[-200, 100, -230, 130, 50, 15, 200, 20])
# 繪製皮卡丘右眼
self.draw_eye(location=[200, 100, 210, 135, 48, 10, 600, 5])
# 繪製左紅暈
self.red_round(location=[-250, -60])
# 繪製右紅暈
self.red_round(location=[290, -60])
# 繪製鼻子
self.draw_nose(location=[-40, 0])
# 繪製輪廓
self.draw_outward(location=[-400, -100])
self.w.exitonclick()
if __name__ == '__main__':
life = Draw()
life.time_draw()