網(wǎng)上有很多關(guān)于pos機(jī)代碼105,用Python代碼畫世界杯吉祥物拉伊卜的知識(shí),也有很多人為大家解答關(guān)于pos機(jī)代碼105的問題,今天pos機(jī)之家(m.dsth100338.com)為大家整理了關(guān)于這方面的知識(shí),讓我們一起來看下吧!
本文目錄一覽:
pos機(jī)代碼105
用Python代碼畫世界杯吉祥物拉伊卜(附代碼)
世界杯正在火熱進(jìn)行中,世界杯的吉祥物拉伊卜也非常火。
本文用Python代碼畫世界杯吉祥物。不廢話直接開整
實(shí)現(xiàn)方法介紹本文的繪圖工具使用Python的標(biāo)準(zhǔn)庫(kù)turtle庫(kù),無需安裝,導(dǎo)入即可使用。
部分函數(shù)用法介紹:
畫布設(shè)置
title(): 設(shè)置窗口的標(biāo)題。
bgpic():設(shè)置背景圖片。
setup(width="360px",height="auto" />
shape():設(shè)置鼠標(biāo)的形狀。
done(): 繪圖結(jié)束后,不自動(dòng)關(guān)閉窗口。
畫筆設(shè)置
pencolor(color): 設(shè)置畫筆顏色。
width="360px",height="auto" />
speed(int): 設(shè)置畫筆的速度,傳入1~10的數(shù)字,1最慢,10最快。傳入其他值會(huì)更快,但是沒有鼠標(biāo)移動(dòng)的動(dòng)畫效果。
penup(): 提起畫筆,提起后移動(dòng)畫筆不會(huì)留下痕跡。
pendown(): 落下畫筆,開始繪圖前先將畫筆落下。
setx(value): 設(shè)置畫筆的x軸坐標(biāo)。
sety(value): 設(shè)置畫筆的y軸坐標(biāo)。
towards(x, y): 設(shè)置畫筆指向的點(diǎn)。
setheading(): 設(shè)置畫筆的方向。與towards()配合可以設(shè)置畫筆指向某個(gè)點(diǎn),如setheading(towards(0, 0))可以設(shè)置畫筆指向原點(diǎn)。
pos(): 返回畫筆當(dāng)前的坐標(biāo)。鼠標(biāo)移動(dòng)一段時(shí)間后可以print()打印此函數(shù)獲取鼠標(biāo)位置。
heading(): 返回畫筆當(dāng)前的方向。
畫筆操作
circle(radius[, extent=arc]): 畫一個(gè)圓,傳入圓的半徑,根據(jù)畫筆的方向控制圓心的位置,圓心與畫筆的方向垂直。傳入弧度值可以畫出指定弧度的圓弧。
left(angle): 畫筆左轉(zhuǎn),傳入任意一個(gè)目標(biāo)角度。
right(angle): 畫筆右轉(zhuǎn)。
forward(distance): 畫筆前進(jìn)一段距離。
backward(distance): 畫筆后退一段距離。
goto(x, y): 移動(dòng)畫筆到指定坐標(biāo)。
顏色填充
begin_fill(): 開始填充。
fillcolor(color): 設(shè)置圖形中填充的顏色。
end_fill(): 結(jié)束填充。
具體畫圖時(shí),調(diào)整畫筆的起點(diǎn),設(shè)置不同的轉(zhuǎn)角度數(shù)和不同的前進(jìn)長(zhǎng)度,可以得到不同形狀的弧線,用弧線構(gòu)成完整的圖形。
部分代碼# coding=utf-8from turtle import *import timedef set_start(x, y, w=0.5, c='black'): # 設(shè)置畫筆開始的位置,繪制每一個(gè)部分的圖形時(shí),將鼠標(biāo)移到起始點(diǎn) penup() # 提起畫筆 setx(x) # 設(shè)置畫筆的x坐標(biāo) sety(y) # 設(shè)置畫筆的y坐標(biāo) setheading(towards(0, 0)) # 默認(rèn)設(shè)置畫筆指向坐標(biāo)原點(diǎn)0,0 width="360px",height="auto" />
angle, length): # 繪制向左轉(zhuǎn)的弧度,左轉(zhuǎn)一定角度然后前進(jìn)一段距離,重復(fù)多次就得到一個(gè)弧度 for i in range(time): # 重復(fù)次數(shù) left(angle) # 左轉(zhuǎn)的角度 forward(length) # 前進(jìn)距離def right_rotate(time, angle, length): # 繪制向右轉(zhuǎn)的弧度,右轉(zhuǎn)一定角度然后前進(jìn)一段距離,重復(fù)多次就得到一個(gè)弧度 for i in range(time): # 重復(fù)次數(shù) right(angle) # 右轉(zhuǎn)的角度 forward(length) # 前進(jìn)距離def fill_color_patch(x, y, c='white'): # 填充顏色時(shí)會(huì)找上一個(gè)圖形的介紹點(diǎn),此函數(shù)重置結(jié)束點(diǎn),避免填充效果不準(zhǔn) set_start(x, y, 1, c=c) forward(1)def draw_circle(radius, color, color2=''): # 繪制一個(gè)圓,radius是圓的半徑,color是邊框顏色,color2是填充顏色 if color2 == '': color2 = color penup() setheading(towards(0, 0)) right(90) pencolor(color) pendown() begin_fill() circle(radius) # 畫圓 fillcolor(color2) end_fill()def draw_football(): # 足球 # set_start(15, -157, w=1, c='black') # draw_circle(39, 'black', '#DCDCDC') fill_color_patch(39.34, -90.63) begin_fill() set_start(39.34, -90.63, w=2, c='black') setheading(124.2) left_rotate(20, 18, 12.2) goto(39.34, -90.63) fillcolor('#DCDCDC') end_fill() fill_color_patch(-25, -110) begin_fill() set_start(-25, -110, w=1, c='white') right_rotate(1, 160, 10) left_rotate(5, 20, 12) left_rotate(4, 18, 12) pencolor('black') left_rotate(1, 35, 12) left_rotate(7, 18, 12.1) goto(-25, -110) fillcolor('white') end_fill() fill_color_patch(-25, -108) begin_fill() set_start(-25, -108, w=1, c='black') right_rotate(1, 20, 4) right_rotate(2, 10, 3) left_rotate(1, 35, 5) left_rotate(1, 165, 5) right_rotate(2, 15, 3) goto(-25, -108) fillcolor('black') end_fill() fill_color_patch(-16, -101) begin_fill() set_start(-16, -101, w=1, c='black') right_rotate(1, 35, 8) right_rotate(1, 140, 4) left_rotate(2, 21, 2) left_rotate(2, 8, 4.5) right_rotate(1, 105, 8) right_rotate(1, 120, 3) left_rotate(3, 15, 4) goto(-16, -101) fillcolor('black') end_fill() fill_color_patch(-10, -93) begin_fill() set_start(-10, -93, w=1, c='black') left_rotate(1, 90, 4) right_rotate(1, 135, 5) right_rotate(2, 3, 7) right_rotate(1, 60, 3) right_rotate(1, 135, 5) left_rotate(3, 10, 4) goto(-10, -93) fillcolor('black') end_fill() fill_color_patch(6, -82) begin_fill() set_start(6, -82, w=1, c='black') right_rotate(1, 50, 4) right_rotate(1, 60, 6) right_rotate(2, 3, 7) right_rotate(1, 130, 4) right_rotate(1, 60, 5) left_rotate(3, 8, 4) goto(6, -82) fillcolor('black') end_fill() fill_color_patch(30, -88) begin_fill() set_start(30, -88, w=1, c='black') right_rotate(1, 130, 5) right_rotate(1, 15, 5) right_rotate(1, 150, 5) goto(30, -88) fillcolor('black') end_fill() fill_color_patch(25, -89) begin_fill() set_start(25, -89, w=1, c='black') right_rotate(1, 140, 8) right_rotate(1, 95, 4) left_rotate(2, 25, 6) right_rotate(1, 130, 8) right_rotate(1, 110, 3) left_rotate(3, 20, 4) goto(25, -89) fillcolor('black') end_fill() fill_color_patch(20, -106) begin_fill() set_start(20, -106, w=1, c='black') right_rotate(1, 180, 8) right_rotate(1, 120, 4) left_rotate(3, 18, 5.8) right_rotate(1, 120, 8) right_rotate(1, 110, 3) left_rotate(3, 14, 5) goto(20, -106) fillcolor('black') end_fill() fill_color_patch(-8, -117) begin_fill() set_start(-8, -117, w=1, c='black') right_rotate(1, 100, 8) right_rotate(1, 115, 4) left_rotate(2, 16, 5) left_rotate(1, 22, 6) right_rotate(1, 125, 8) right_rotate(1, 120, 3) left_rotate(1, 25, 4) left_rotate(3, 15, 4) goto(-8, -117) fillcolor('black') end_fill() fill_color_patch(-12, -137) begin_fill() set_start(-12, -137, w=1, c='black') right_rotate(1, 145, 8) right_rotate(1, 148, 4) left_rotate(2, 18, 3.2) right_rotate(1, 55, 7) right_rotate(1, 165, 3) left_rotate(3, 20, 3) goto(-12, -137) fillcolor('black') end_fill() fill_color_patch(-6, -144) begin_fill() set_start(-6, -144, w=1, c='black') right_rotate(1, 35, 6) right_rotate(1, 105, 4) left_rotate(3, 16, 5.5) right_rotate(1, 130, 5) right_rotate(1, 78, 3) left_rotate(3, 5, 4) goto(-6, -144) fillcolor('black') end_fill() fill_color_patch(23, -115) begin_fill() set_start(23, -115, w=1, c='black') right_rotate(1, 60, 8) right_rotate(1, 120, 4) left_rotate(3, 12, 5.3) right_rotate(1, 100, 8) right_rotate(1, 130, 3) left_rotate(3, 15, 5) goto(23, -115) fillcolor('black') end_fill() fill_color_patch(32, -133) begin_fill() set_start(32, -133, w=1, c='black') right_rotate(1, 140, 6) right_rotate(1, 110, 4) left_rotate(3, 8, 5) right_rotate(1, 80, 7) right_rotate(1, 140, 3) left_rotate(3, 14, 6) goto(32, -133) fillcolor('black') end_fill() fill_color_patch(39, -135) begin_fill() set_start(39, -135, w=1, c='black') right_rotate(1, 30, 7) right_rotate(1, 80, 3) left_rotate(3, 20, 2.2) right_rotate(1, 160, 5) right_rotate(1, 60, 3) left_rotate(2, 15, 3) goto(39, -135) fillcolor('black') end_fill() fill_color_patch(14, -153) begin_fill() set_start(14, -153, w=1, c='black') right_rotate(1, 90, 7) right_rotate(1, 130, 3.5) right_rotate(1, 60, 3) goto(14, -153) fillcolor('black') end_fill()if __name__ == '__main__': title('世界杯吉祥物拉伊卜Laeeb(公眾號(hào):小斌哥ge)') wide = 600 height = 500 screensize(wide, height, '#FF0049') setup(wide+30, height+30, 100, 50) shape(name='turtle') time.sleep(2) # draw_body() # draw_head() # draw_mouth() # draw_eye() # draw_cap() # draw_hair() draw_football() # draw_clothes() set_start(1000, 1000, 1) done()代碼獲取獲.得源碼 的方式
轉(zhuǎn)/發(fā)/本文,私信:世界杯,
即可獲??!
↓↓↓不會(huì)私信地看下圖
↓↓↓
↑↑↑不會(huì)私信地看上圖
↑↑↑
以上就是關(guān)于pos機(jī)代碼105,用Python代碼畫世界杯吉祥物拉伊卜的知識(shí),后面我們會(huì)繼續(xù)為大家整理關(guān)于pos機(jī)代碼105的知識(shí),希望能夠幫助到大家!
