基于Python-turtle庫(kù)繪制路飛的草帽骷髏旗、美國(guó)隊(duì)長(zhǎng)的盾牌、高達(dá)的源碼
源碼:
#路飛骷髏 import turtle as t #黃底帽子 t.pu() t.goto(0,200) t.circle(-130,-80) t.pd() t.colormode(255) t.pensize(5) t.color(242,232,184) #帽子黃底R(shí)GB t.begin_fill() t.pencolor(0,0,0) t.circle(-130,160) t.seth(180) t.fd(255) t.end_fill() #紅色線條 t.begin_fill() t.color(221,65,43) #帽子紅色帶 t.pencolor(0,0,0) t.seth(80) t.circle(-130,19) t.seth(0) t.fd(225) t.seth(-59) t.circle(-130,19) t.seth(180) t.fd(255) t.end_fill() #帽檐 t.begin_fill() t.color(242,232,184) t.pencolor(0,0,0) t.fd(60) t.circle(12,180) t.fd(375) t.circle(12,180) t.fd(255 + 60) t.end_fill() #臉部下半輪廓 t.pu() t.setpos(0,-30) t.seth(-180) t.circle(-130,-75) t.pd() t.circle(-130,150) #眼睛鼻子 t.pu() t.color(33,24,24) #眼睛、鼻子RGB t.setpos(-45,64) t.seth(-180) t.pd() t.begin_fill() t.circle(33) t.pu() t.setpos(45,64) t.pd() t.circle(33) t.end_fill() t.pu() t.setpos(0,5) t.pd() t.begin_fill() t.circle(8) t.end_fill() #下巴 t.pencolor(0,0,0) t.pu() t.setpos(0,0) t.seth(0) t.circle(-75,45) t.pd() t.circle(-75,270) #牙齒 t.pu() t.setpos(0,120) t.seth(0) t.circle(-105,136) t.pd() t.circle(-105,86) t.pu() t.seth(0) t.goto(0,200) t.circle(-130,150) t.pd() t.circle(-130,60) t.pu() #牙齒三根豎線 t.setpos(-30,-27) t.seth(260) t.pd() t.fd(52) t.pu() t.setpos(30,-27) t.pd() t.seth(-260) t.fd(-52) t.pu() t.setpos(0,-30) t.seth(-90) t.pd() t.fd(56) #上排右側(cè)小爪爪 #釋放注釋為:上排右側(cè)小爪爪實(shí)心金方案 t.pu() #t.color(255,215,0) #金色的RGB t.pencolor(0,0,0) t.setpos(110,145) t.seth(45) t.pd() #t.begin_fill() t.fd(40) t.seth(135) t.circle(-30,235) t.seth(-20) t.circle(-30,220) t.seth(-135) t.fd(40) #t.end_fill() #上排左側(cè)小爪爪 t.pu() t.pencolor(0,0,0) t.setpos(-110,145) t.seth(135) t.pd() t.fd(40) t.seth(45) t.circle(30,235) t.seth(-160) t.circle(30,220) t.seth(-45) t.fd(40) #下排右側(cè)小爪爪 t.pu() t.setpos(70,-10) t.seth(-45) t.pd() t.fd(70) t.seth(45) t.circle(-30,235) t.seth(-70) t.circle(-30,255) t.seth(135) t.fd(22) #下排左側(cè)小爪爪 t.pu() t.setpos(-70,-10) t.seth(-135) t.pd() t.fd(70) t.seth(135) t.circle(30,235) t.seth(-110) t.circle(30,255) t.seth(45) t.fd(22) t.done()
效果圖:
源碼:
# -*- coding:utf-8 -*- import turtle import math def shield(): ''' 該函數(shù)的作用是畫(huà)一個(gè)美國(guó)隊(duì)長(zhǎng)的盾牌 ''' # 設(shè)置畫(huà)布背景 turtle.bgcolor('#FFFFFF') # 設(shè)置畫(huà)筆速度 turtle.speed(10) # 依次填充同心圓 fill_circle('#FF0000', 230) fill_circle('#FFFFFF', 178) fill_circle('#FF0000', 129) fill_circle('#0000FF', 75) # 完成五角星 draw_five('#FFFFFF', 75) # 以下代碼,將畫(huà)好的圖案按指定格式保存到當(dāng)前文件目錄 # windows 可以使用.jpg格式,或.ps,MAC使用eps格式,或.ps ts = turtle.getscreen() ts.getcanvas().postscript(file="shield.eps") # 啟動(dòng)事件循環(huán),必須是烏龜圖形程序中的最后一個(gè)語(yǔ)句 # 如果沒(méi)有這個(gè)語(yǔ)句,代碼運(yùn)行完成后,窗口直接消失。 turtle.done() def draw_circle(radium): ''' 該函數(shù)的作用是畫(huà)一個(gè)圓線 :param radium:半徑 ''' # 畫(huà)筆定位到圓點(diǎn) turtle.home() # 提筆 turtle.penup() # 向前移動(dòng)指定的半徑 turtle.forward(radium) # 落筆 turtle.pendown() # 偏轉(zhuǎn)角度 turtle.setheading(90) # 畫(huà)一個(gè)指定半徑的圓 turtle.circle(radium) # 提筆 turtle.penup() def fill_circle(color, r1): ''' 該函數(shù)的作用是,畫(huà)一個(gè)圓環(huán),有指定的填充色和半徑 :param color:顏色 :param r1:半徑 ''' # 設(shè)置畫(huà)筆顏色 turtle.pencolor(color) # 設(shè)置填充顏色 turtle.fillcolor(color) # 開(kāi)始填充 turtle.begin_fill() # 畫(huà)圓線 draw_circle(r1) # 結(jié)束填充 turtle.end_fill() # 畫(huà)并填充五角星 def draw_five(color, radium): ''' 該函數(shù)的作用是畫(huà)一個(gè)五角星 :param color:顏色 :para radium: ''' # 畫(huà)筆定位到圓點(diǎn) turtle.home() # 提筆 turtle.penup() # 偏轉(zhuǎn)90度 turtle.setheading(90) # 向前移動(dòng)90個(gè)像素 turtle.forward(radium) # 偏轉(zhuǎn)288度 turtle.setheading(288) # 落筆 turtle.pendown() # radians()將角度轉(zhuǎn)換為弧度 long_side = (math.sin(math.radians(36))*radium)/math.sin(math.radians(126)) # 設(shè)置畫(huà)筆顏色 turtle.pencolor(color) # 設(shè)置填充顏色 turtle.fillcolor(color) # 開(kāi)始填充 turtle.begin_fill() for i in range(10): turtle.forward(long_side) if i % 2 == 0: turtle.left(72) else: turtle.right(144) # 結(jié)束填充 turtle.end_fill() # 提筆 turtle.penup() # 運(yùn)行主函數(shù) shield()
效果圖:
源碼:
import turtle t=turtle.Turtle() turtle.Turtle().screen.delay(0) tleft=turtle.Turtle() #第一部分 t.penup() t.goto(0,0) t.pendown() t.left(20) t.forward(110) t.left(25) t.forward(40) t.left(100) t.circle(180,20) t.right(120) t.forward(250) t.left(165) t.forward(250) t.right(100) t.forward(35) t.left(70) t.forward(45) t.left(70) t.forward(120) t.left(70) t.forward(80) t.left(80) t.forward(80) t.left(68) t.forward(120) t.left(180) t.forward(78) t.right(68) t.forward(60) t.right(75) t.forward(60) t.right(110) t.forward(15) t.left(38) t.forward(65) t.right(73)#五邊形的直邊 t.forward(35) t.right(70) t.forward(65) t.right(68) t.forward(50) t.right(80) t.forward(50) t.penup() t.goto(-65,68) t.pendown() t.right(7) t.forward(350) t.right(165) t.forward(330) t.penup() t.goto(64,65) t.pendown() t.left(75) t.forward(350) t.left(165) t.forward(330) t.penup() t.goto(300,500) #第二部分 tleft.left(180) tleft.right(20) tleft.forward(110) tleft.right(25) tleft.forward(40) tleft.right(100) tleft.circle(-180,20) tleft.left(120) tleft.forward(250) tleft.right(165) tleft.forward(250) tleft.left(100) tleft.forward(35) tleft.penup() tleft.goto(0,0) tleft.pendown() tleft.left(20) tleft.penup() tleft.forward(18) tleft.pendown() tleft.forward(50)#額頭豎線 tleft.penup() tleft.forward(110)#消除豎線 tleft.pendown() tleft.left(90) tleft.forward(30) tleft.right(90) tleft.forward(60) tleft.right(90) tleft.forward(60) tleft.right(90) tleft.forward(60) tleft.right(90) tleft.forward(40) tleft.penup() tleft.forward(30) tleft.pendown() tleft.left(90) tleft.forward(30) tleft.right(180) tleft.forward(100) tleft.right(90) tleft.forward(80) tleft.right(90) tleft.forward(100) tleft.penup() tleft.goto(150,70) tleft.pendown() tleft.left(100) tleft.forward(40) tleft.right(80) tleft.circle(-333,40) tleft.right(160) tleft.forward(230) #右半部分 tleft.left(100) tleft.forward(40) tleft.left(80) tleft.forward(20) tleft.left(100) tleft.forward(30) tleft.right(100) tleft.forward(20) tleft.right(80) tleft.forward(30) tleft.left(80) tleft.forward(20) tleft.left(100) tleft.forward(30) tleft.right(100) tleft.forward(20) tleft.right(80) tleft.forward(30) tleft.left(80) tleft.forward(20) tleft.left(100) tleft.forward(30) tleft.right(100) tleft.forward(20) tleft.right(80) tleft.forward(30) tleft.left(80) tleft.forward(20) tleft.left(100) tleft.forward(30) tleft.right(100) tleft.forward(20) tleft.right(80) tleft.forward(30) tleft.left(80) tleft.forward(20) tleft.left(100) tleft.forward(30) tleft.right(100) tleft.forward(20) tleft.right(80) tleft.forward(30) tleft.left(80) tleft.forward(20) tleft.left(100) tleft.forward(30) tleft.right(100) tleft.forward(20) tleft.right(80) tleft.forward(30) #右下部分 tleft.left(70) tleft.forward(30) tleft.right(110) tleft.forward(40) tleft.right(60) tleft.forward(100) tleft.right(30) tleft.circle(200,20) tleft.left(10) tleft.forward(80) #右下部分goto tleft.penup() tleft.goto(145,-198) tleft.pendown() tleft.left(90) tleft.forward(30) tleft.right(30) tleft.forward(40) tleft.right(150) tleft.forward(30) tleft.backward(30) tleft.left(90) tleft.forward(100) tleft.right(90) tleft.forward(30) tleft.backward(30) tleft.left(90) tleft.right(30) tleft.circle(200,20) tleft.left(10) tleft.forward(50) #第三部分臉 t2=turtle.Turtle() t2.penup() t2.goto(0,-80) #尖角 t2.circle(150,extent=90) t2.pendown() t2.circle(150,extent=30) t2.penup() t2.circle(150,extent=18) t2.pendown() t2.circle(150,extent=27) t2.penup() t2.circle(150,extent=30) t2.pendown() t2.circle(150,extent=27) t2.penup() t2.circle(150,extent=18) t2.pendown() t2.circle(150,extent=30) t2.right(100) t2.forward(40) #左臉夾 t2.left(80) t2.circle(333,40) t2.left(160) t2.forward(230) #左半部分 t2.right(100) t2.forward(40) t2.right(80) t2.forward(20) t2.right(100) t2.forward(30) t2.left(100) t2.forward(20) t2.left(80) t2.forward(30) t2.right(80) t2.forward(20) t2.right(100) t2.forward(30) t2.left(100) t2.forward(20) t2.left(80) t2.forward(30) t2.right(80) t2.forward(20) t2.right(100) t2.forward(30) t2.left(100) t2.forward(20) t2.left(80) t2.forward(30) t2.right(80) t2.forward(20) t2.right(100) t2.forward(30) t2.left(100) t2.forward(20) t2.left(80) t2.forward(30) t2.right(80) t2.forward(20) t2.right(100) t2.forward(30) t2.left(100) t2.forward(20) t2.left(80) t2.forward(30) t2.right(80) t2.forward(20) t2.right(100) t2.forward(30) t2.left(100) t2.forward(20) t2.left(80) t2.forward(30) t2.right(70) t2.forward(30) t2.left(110) t2.forward(40) t2.left(60) t2.forward(100) t2.left(30) t2.circle(-200,20) t2.right(10) t2.forward(80) t2.penup() t2.goto(-145,-198)#左臉頰 t2.pendown() t2.right(90) t2.forward(30) t2.left(30) t2.forward(40) t2.left(150) t2.forward(30) t2.right(180) t2.forward(30) t2.left(90) t2.forward(100) t2.left(90) t2.forward(30) t2.left(180) t2.forward(30) t2.left(120) t2.circle(-200,20) t2.right(10) t2.forward(50) #左眼 t2.right(135) t2.forward(70) t2.left(50) t2.forward(40) t2.left(20) t2.forward(20) t2.penup() t2.goto(-100,28) t2.pendown() t2.right(70) t2.forward(65) t2.left(50) t2.forward(40) t2.left(40) t2.forward(20) #左眼帶 t2.penup() t2.goto(-105,-10) t2.pendown() t2.right(100) t2.circle(120,extent=20) t2.circle(60,extent=80) t2.penup() t2.goto(-105,-13) t2.pendown() t2.right(100) t2.circle(120,extent=20) t2.circle(60,extent=80) t2.penup() t2.goto(-70,-40) t2.pendown() t2.left(10) t2.forward(30) t2.penup() t2.goto(-10,-40) t2.pendown() t2.left(35) t2.forward(30) t2.penup() t2.goto(-80,30) t2.pendown() t2.right(130) t2.forward(47) t2.left(50) t2.forward(35) t2.penup() t2.goto(-60,-45) t2.pendown() t2.right(98) t2.forward(60) t2.left(20) t2.forward(80) t2.left(70) t2.forward(10) t2.left(90) t2.forward(50) t2.right(60) t2.forward(30) t2.right(60) t2.forward(30) t2.right(60) t2.forward(50) t2.left(90) t2.forward(10) t2.left(75) t2.forward(80) t2.left(15) t2.forward(60) t2.penup() t2.goto(-80,-140) t2.pendown() t2.right(150) t2.circle(85,extent=45) t2.left(15) t2.forward(70) t2.left(15) t2.circle(55,extent=55) t2.penup() t2.goto(0,-175) t2.pendown() t2.left(18) t2.forward(170) #右眼 tleft.left(135) tleft.forward(70) tleft.right(50) tleft.forward(40) tleft.right(20) tleft.forward(20) tleft.penup() tleft.goto(100,28) tleft.pendown() tleft.left(70) tleft.forward(65) tleft.right(50) tleft.forward(40) tleft.right(40) tleft.forward(20) #右眼帶 tleft.penup() tleft.goto(105,-10) tleft.pendown() tleft.left(100) tleft.circle(-120,extent=20) tleft.circle(-60,extent=80) tleft.penup() tleft.goto(105,-13) tleft.pendown() tleft.left(100) tleft.circle(-120,extent=20) tleft.circle(-60,extent=80) #右眼睛 tleft.penup() tleft.goto(70,-40) tleft.pendown() tleft.right(10) tleft.forward(30) tleft.penup() tleft.goto(10,-40) tleft.pendown() tleft.right(35) tleft.forward(30) tleft.penup() tleft.goto(80,30) tleft.pendown() tleft.left(130) tleft.forward(47) tleft.right(50) tleft.forward(35) #鼻子 tleft.penup() tleft.goto(0,-70) tleft.pendown() tleft.left(30) tleft.forward(20) tleft.left(72) tleft.forward(10) tleft.left(108) tleft.forward(20) tleft.right(42) tleft.forward(20) tleft.left(108) tleft.forward(10) tleft.left(72) tleft.forward(20) tleft.penup() tleft.goto(0,-90) tleft.pendown() tleft.left(42) tleft.forward(20) tleft.left(72) tleft.forward(10) tleft.left(108) tleft.forward(20) tleft.right(42) tleft.forward(20) tleft.left(108) tleft.forward(10) tleft.left(72) tleft.forward(20) tleft.penup() tleft.goto(200,500) turtle.done()
效果圖:
到此這篇關(guān)于基于Python-turtle庫(kù)繪制路飛的草帽骷髏旗、美國(guó)隊(duì)長(zhǎng)的盾牌、高達(dá)的文章就介紹到這了,更多相關(guān)Python-turtle庫(kù)美國(guó)隊(duì)長(zhǎng)的盾牌內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- python繪圖模塊之利用turtle畫(huà)圖
- 詳解Python繪圖Turtle庫(kù)
- Python內(nèi)置模塊turtle繪圖詳解
- python 簡(jiǎn)單的繪圖工具turtle使用詳解
- Python趣味挑戰(zhàn)之turtle庫(kù)繪畫(huà)飄落的銀杏樹(shù)
- 教你利用Python+Turtle繪制簡(jiǎn)易版愛(ài)心表白
- Python使用Turtle模塊繪制國(guó)旗的方法示例
- python中turtle庫(kù)的簡(jiǎn)單使用教程
- Python turtle庫(kù)的畫(huà)筆控制說(shuō)明
- python基于turtle繪制幾何圖形
相關(guān)文章
在pytorch中如何查看模型model參數(shù)parameters
這篇文章主要介紹了在pytorch中如何查看模型model參數(shù)parameters,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-11-11Python中判斷語(yǔ)句入門指南(if?elif?else語(yǔ)句)
if elif else語(yǔ)句是Python中的控制語(yǔ)句,用于根據(jù)條件執(zhí)行不同的操作,下面這篇文章主要給大家介紹了關(guān)于Python中判斷語(yǔ)句入門指南(if?elif?else語(yǔ)句)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05python非單一.py文件用Pyinstaller打包發(fā)布成exe
第一次將自己做的python爬蟲(chóng)項(xiàng)目打包成exe,所以留個(gè)筆記,本文詳細(xì)的介紹了python非單一.py文件用Pyinstaller打包發(fā)布成exe,具有一定的參考價(jià)值,感興趣的可以了解一下2022-03-03基于Python實(shí)現(xiàn)一鍵找出磁盤里所有貓照
最近在整理我磁盤上的照片,發(fā)現(xiàn)不少貓照,突然覺(jué)得若能把這些貓照都挑出來(lái),觀察它們的成長(zhǎng)軌跡也是一件不錯(cuò)的事情。一張一張的找實(shí)在是太費(fèi)勁了,能不能自動(dòng)化地找出來(lái)呢?本文將詳細(xì)為大家講講,需要的可以參考一下2022-05-05Python中ROS和OpenCV結(jié)合處理圖像問(wèn)題
ROS通過(guò)一個(gè)叫CvBridge的功能包,將獲取的圖像數(shù)據(jù)轉(zhuǎn)換成OpenCV的格式,OpenCV處理之后,傳回給ROS進(jìn)行圖像顯示(應(yīng)用),這篇文章主要介紹了Python中ROS和OpenCV結(jié)合處理圖像問(wèn)題,需要的朋友可以參考下2022-06-06使用PyInstaller將Python代碼打包成獨(dú)立可執(zhí)行文件詳細(xì)步驟
PyInstaller是一個(gè)Python庫(kù),可以將Python應(yīng)用程序轉(zhuǎn)換為獨(dú)立的可執(zhí)行文件,這篇文章主要給大家介紹了關(guān)于使用PyInstaller將Python代碼打包成獨(dú)立可執(zhí)行文件的詳細(xì)步驟,需要的朋友可以參考下2024-07-07