首頁>技術>

小豬佩奇

# coding:utf-8import turtle as tt.pensize(4) # 設定畫筆的大小t.colormode(255) # 設定GBK顏色範圍為0-255t.color((255,155,192),"pink") # 設定畫筆顏色和填充顏色(pink)t.setup(840,500) # 設定主視窗的大小為840*500t.speed(10) # 設定畫筆速度為10#鼻子t.pu() # 提筆t.goto(-100,100) # 畫筆前往座標(-100,100)t.pd() # 下筆t.seth(-30) # 筆的角度為-30°t.begin_fill() # 外形填充的開始標誌a=0.4for i in range(120):   if 0<=i<30 or 60<=i<90:       a=a+0.08       t.lt(3) #向左轉3度       t.fd(a) #向前走a的步長   else:       a=a-0.08       t.lt(3)       t.fd(a)t.end_fill() # 依據輪廓填充t.pu() # 提筆t.seth(90) # 筆的角度為90度t.fd(25) # 向前移動25t.seth(0) # 轉換畫筆的角度為0t.fd(10)t.pd()t.pencolor(255,155,192) # 設定畫筆顏色t.seth(10)t.begin_fill()t.circle(5) # 畫一個半徑為5的圓t.color(160,82,45) # 設定畫筆和填充顏色t.end_fill()t.pu()t.seth(0)t.fd(20)t.pd()t.pencolor(255,155,192)t.seth(10)t.begin_fill()t.circle(5)t.color(160,82,45)t.end_fill()#頭t.color((255,155,192),"pink")t.pu()t.seth(90)t.fd(41)t.seth(0)t.fd(0)t.pd()t.begin_fill()t.seth(180)t.circle(300,-30) # 順時針畫一個半徑為300,圓心角為30°的園t.circle(100,-60)t.circle(80,-100)t.circle(150,-20)t.circle(60,-95)t.seth(161)t.circle(-300,15)t.pu()t.goto(-100,100)t.pd()t.seth(-30)a=0.4for i in range(60):   if 0<=i<30 or 60<=i<90:       a=a+0.08       t.lt(3) #向左轉3度       t.fd(a) #向前走a的步長   else:       a=a-0.08       t.lt(3)       t.fd(a)t.end_fill()#耳朵t.color((255,155,192),"pink")t.pu()t.seth(90)t.fd(-7)t.seth(0)t.fd(70)t.pd()t.begin_fill()t.seth(100)t.circle(-50,50)t.circle(-10,120)t.circle(-50,54)t.end_fill()t.pu()t.seth(90)t.fd(-12)t.seth(0)t.fd(30)t.pd()t.begin_fill()t.seth(100)t.circle(-50,50)t.circle(-10,120)t.circle(-50,56)t.end_fill()#眼睛t.color((255,155,192),"white")t.pu()t.seth(90)t.fd(-20)t.seth(0)t.fd(-95)t.pd()t.begin_fill()t.circle(15)t.end_fill()t.color("black")t.pu()t.seth(90)t.fd(12)t.seth(0)t.fd(-3)t.pd()t.begin_fill()t.circle(3)t.end_fill()t.color((255,155,192),"white")t.pu()t.seth(90)t.fd(-25)t.seth(0)t.fd(40)t.pd()t.begin_fill()t.circle(15)t.end_fill()t.color("black")t.pu()t.seth(90)t.fd(12)t.seth(0)t.fd(-3)t.pd()t.begin_fill()t.circle(3)t.end_fill()#腮t.color((255,155,192))t.pu()t.seth(90)t.fd(-95)t.seth(0)t.fd(65)t.pd()t.begin_fill()t.circle(30)t.end_fill()#嘴t.color(239,69,19)t.pu()t.seth(90)t.fd(15)t.seth(0)t.fd(-100)t.pd()t.seth(-80)t.circle(30,40)t.circle(40,80)#身體t.color("red",(255,99,71))t.pu()t.seth(90)t.fd(-20)t.seth(0)t.fd(-78)t.pd()t.begin_fill()t.seth(-130)t.circle(100,10)t.circle(300,30)t.seth(0)t.fd(230)t.seth(90)t.circle(300,30)t.circle(100,3)t.color((255,155,192),(255,100,100))t.seth(-135)t.circle(-80,63)t.circle(-150,24)t.end_fill()#手t.color((255,155,192))t.pu()t.seth(90)t.fd(-40)t.seth(0)t.fd(-27)t.pd()t.seth(-160)t.circle(300,15)t.pu()t.seth(90)t.fd(15)t.seth(0)t.fd(0)t.pd()t.seth(-10)t.circle(-20,90)t.pu()t.seth(90)t.fd(30)t.seth(0)t.fd(237)t.pd()t.seth(-20)t.circle(-300,15)t.pu()t.seth(90)t.fd(20)t.seth(0)t.fd(0)t.pd()t.seth(-170)t.circle(20,90)#腳t.pensize(10)t.color((240,128,128))t.pu()t.seth(90)t.fd(-75)t.seth(0)t.fd(-180)t.pd()t.seth(-90)t.fd(40)t.seth(-180)t.color("black")t.pensize(15)t.fd(20)t.pensize(10)t.color((240,128,128))t.pu()t.seth(90)t.fd(40)t.seth(0)t.fd(90)t.pd()t.seth(-90)t.fd(40)t.seth(-180)t.color("black")t.pensize(15)t.fd(20)#尾巴t.pensize(4)t.color((255,155,192))t.pu()t.seth(90)t.fd(70)t.seth(0)t.fd(95)t.pd()t.seth(0)t.circle(70,20)t.circle(10,330)t.circle(70,30)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264

結果:

多來a夢
# * -- utf-8 -- *# Author: Tang import turtle as t t.speed(10)t.pensize(8)t.hideturtle()t.screensize(500, 500, bg='white') # 貓臉t.fillcolor('#00A1E8')t.begin_fill()t.circle(120)t.end_fill() t.pensize(3)t.fillcolor('white')t.begin_fill()t.circle(100)t.end_fill() t.pu()t.home()t.goto(0, 134)t.pd()t.pensize(4)t.fillcolor("#EA0014")t.begin_fill()t.circle(18)t.end_fill() t.pu()t.goto(7, 155)t.pensize(2)t.color('white', 'white')t.pd()t.begin_fill()t.circle(4)t.end_fill() t.pu()t.goto(-30, 160)t.pensize(4)t.pd()t.color('black', 'white')t.begin_fill()a = 0.4for i in range(120):    if 0 <= i < 30 or 60 <= i < 90:        a = a+0.08        t.lt(3) #向左轉3度        t.fd(a) #向前走a的步長    else:        a = a-0.08        t.lt(3)        t.fd(a)t.end_fill() t.pu()t.goto(30, 160)t.pensize(4)t.pd()t.color('black', 'white')t.begin_fill()for i in range(120):    if 0 <= i < 30 or 60 <= i < 90:        a = a+0.08        t.lt(3)  # 向左轉3度        t.fd(a)  # 向前走a的步長    else:        a = a-0.08        t.lt(3)        t.fd(a)t.end_fill() t.pu()t.goto(-38,190)t.pensize(8)t.pd()t.right(-30)t.forward(15)t.right(70)t.forward(15) t.pu()t.goto(15, 185)t.pensize(4)t.pd()t.color('black', 'black')t.begin_fill()t.circle(13)t.end_fill() t.pu()t.goto(13, 190)t.pensize(2)t.pd()t.color('white', 'white')t.begin_fill()t.circle(5)t.end_fill() t.pu()t.home()t.goto(0, 134)t.pensize(4)t.pencolor('black')t.pd()t.right(90)t.forward(40) t.pu()t.home()t.goto(0, 124)t.pensize(3)t.pencolor('black')t.pd()t.left(10)t.forward(80) t.pu()t.home()t.goto(0, 114)t.pensize(3)t.pencolor('black')t.pd()t.left(6)t.forward(80) t.pu()t.home()t.goto(0,104)t.pensize(3)t.pencolor('black')t.pd()t.left(0)t.forward(80) # 左邊的鬍子t.pu()t.home()t.goto(0,124)t.pensize(3)t.pencolor('black')t.pd()t.left(170)t.forward(80) t.pu()t.home()t.goto(0, 114)t.pensize(3)t.pencolor('black')t.pd()t.left(174)t.forward(80) t.pu()t.home()t.goto(0, 104)t.pensize(3)t.pencolor('black')t.pd()t.left(180)t.forward(80) t.pu()t.goto(-70, 70)t.pd()t.color('black', 'red')t.pensize(6)t.seth(-60)t.begin_fill()t.circle(80,40)t.circle(80,80)t.end_fill() t.pu()t.home()t.goto(-80,70)t.pd()t.forward(160) t.pu()t.home()t.goto(-50,50)t.pd()t.pensize(1)t.fillcolor("#eb6e1a")t.seth(40)t.begin_fill()t.circle(-40, 40)t.circle(-40, 40)t.seth(40)t.circle(-40, 40)t.circle(-40, 40)t.seth(220)t.circle(-80, 40)t.circle(-80, 40)t.end_fill() # 領帶t.pu()t.goto(-70, 12)t.pensize(14)t.pencolor('red')t.pd()t.seth(-20)t.circle(200, 30)t.circle(200, 10) # 鈴鐺t.pu()t.goto(0, -46)t.pd()t.pensize(3)t.color("black", '#f8d102')t.begin_fill()t.circle(25)t.end_fill()  t.pu()t.goto(-5, -40)t.pd()t.pensize(2)t.color("black", '#79675d')t.begin_fill()t.circle(5)t.end_fill() t.pensize(3)t.right(115)t.forward(7) t.mainloop()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236

結果:

皮卡丘
#!/usr/bin/env python # -*- coding:utf-8 -*-from turtle import *'''繪製皮卡丘頭部'''def face(x,y):    """畫臉"""    begin_fill()    penup()    # 將海龜移動到指定的座標    goto(x, y)    pendown()    # 設定海龜的方向    setheading(40)    circle(-150, 69)    fillcolor("#FBD624")    # 將海龜移動到指定的座標        penup()    goto(53.14, 113.29)    pendown()        setheading(300)    circle(-150, 30)    setheading(295)    circle(-140, 20)    print(position())    forward(5)    setheading(260)    circle(-80, 70)    print(position())    penup()    goto(-74.43,-79.09)    pendown()    penup()    # 將海龜移動到指定的座標    goto(-144,103)    pendown()    setheading(242)    circle(110, 35)    right(10)    forward(10)    setheading(250)    circle(80, 115)    print(position())    penup()    goto(-74.43,-79.09)    pendown()    setheading(10)    penup()    goto(-144, 103)    pendown()    penup()    goto(x, y)    pendown()    end_fill()    # 下巴    penup()    goto(-50, -82.09)    pendown()    pencolor("#DDA120")    fillcolor("#DDA120")    begin_fill()    setheading(-12)    circle(120, 25)    setheading(-145)    forward(30)    setheading(180)    circle(-20, 20)    setheading(143)    forward(30)    end_fill()    # penup()    # # 將海龜移動到指定的座標    # goto(0, 0)    # pendown()def eye():    """畫眼睛"""    # 左眼    color("black","black")    penup()    goto(-110, 27)    pendown()    begin_fill()    setheading(0)    circle(24)    end_fill()    # 左眼仁    color("white", "white")    penup()    goto(-105, 51)    pendown()    begin_fill()    setheading(0)    circle(10)    end_fill()    # 右眼    color("black", "black")    penup()    goto(25, 40)    pendown()    begin_fill()    setheading(0)    circle(24)    end_fill()    # 右眼仁    color("white", "white")    penup()    goto(17, 62)    pendown()    begin_fill()    setheading(0)    circle(10)    end_fill()def cheek():    """畫臉頰"""    # 右邊    color("#9E4406", "#FE2C21")    penup()    goto(-130, -50)    pendown()    begin_fill()    setheading(0)    circle(27)    end_fill()    # 左邊    color("#9E4406", "#FE2C21")    penup()    goto(53, -20)    pendown()    begin_fill()    setheading(0)    circle(27)    end_fill()def nose():    """畫鼻子"""    color("black", "black")    penup()    goto(-40, 38)    pendown()    begin_fill()    circle(7,steps = 3)    end_fill()def mouth():    """畫嘴"""    color("black", "#F35590")    # 嘴唇    penup()    goto(-10, 22)    pendown()    begin_fill()    setheading(260)    forward(60)    circle(-11, 150)    forward(55)    print(position())    penup()    goto(-38.46, 21.97)    pendown()    end_fill()    # 舌頭    color("#6A070D", "#6A070D")    begin_fill()    penup()    goto(-10.00, 22.00)    pendown()    penup()    goto(-14.29, -1.7)    pendown()    penup()    goto(-52, -5)    pendown()    penup()    goto(-60.40, 12.74)    pendown()    penup()    goto(-38.46, 21.97)    pendown()    penup()    goto(-10.00, 22.00)    pendown()    end_fill()    color("black","#FFD624")    penup()    goto(-78, 15)    pendown()    begin_fill()    setheading(-25)    for i in range(2):        setheading(-25)        circle(35, 70)    end_fill()    color("#AB1945", "#AB1945")    penup()    goto(-52, -5)    pendown()    begin_fill()    setheading(40)    circle(-33, 70)    goto(-16,-1.7)    penup()    goto(-18,-17)    pendown()    setheading(155)    circle(25, 70)    end_fill()def ear():    """畫耳朵"""    # 左耳    color("black","#FFD624")    penup()    goto(-145, 93)    pendown()    begin_fill()    setheading(165)    circle(-248,50)    right(120)    circle(-248,50)    end_fill()    color("black", "black")    penup()    goto(-240, 143)    pendown()    begin_fill()    setheading(107)    circle(-170, 25)    left(80)    circle(229, 15)    left(120)    circle(300, 15)    end_fill()    # 右耳    color("black", "#FFD624")    penup()    goto(30, 136)    pendown()    begin_fill()    setheading(64)    circle(-248, 50)    right(120)    circle(-248, 50)    end_fill()    color("black", "black")    penup()    goto(160, 200)    pendown()    begin_fill()    setheading(52)    circle(170, 25)    left(116)    circle(229, 15)    left(71)    circle(-300, 15)    end_fill()def setting():    """設定引數"""    pensize(2)    # 隱藏海龜    hideturtle()    speed(10)def main():    """主函式"""    setting()    face(-132,115)    eye()    cheek()    nose()    mouth()    ear()    done()if __name__ == '__main__':    main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297

結果:

小烏龜
import turtleturtle.setup(1000,800)turtle.speed(6)turtle.colormode(255)turtle.color((0,0,0),(60,100,30))turtle.penup()turtle.goto(0,-200)turtle.pendown()turtle.begin_fill()turtle.circle(200)turtle.end_fill()turtle.pensize(2)turtle.penup()turtle.goto(190,-60)turtle.pendown()turtle.goto(-190,-60)turtle.penup()turtle.goto(190,60)turtle.pendown()turtle.goto(-190,60)turtle.penup()turtle.goto(60,190)turtle.pendown()turtle.goto(60,-190)turtle.penup()turtle.goto(-60,190)turtle.pendown()turtle.goto(-60,-190)turtle.penup()turtle.pensize(1)turtle.goto(20,198)turtle.penup()turtle.goto(0,200)turtle.pendown()turtle.color((0,0,0),(60,80,30))turtle.begin_fill()a=1turtle.speed(0)for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.04        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.04        turtle.lt(3)        turtle.fd(a)turtle.penup()turtle.end_fill()turtle.color((0,0,0),(255,255,255))turtle.goto(11,240)turtle.begin_fill()turtle.pendown()turtle.circle(5)turtle.end_fill()turtle.penup()turtle.end_fill()turtle.color((0,0,0),(255,255,255))turtle.goto(-11,240)turtle.begin_fill()turtle.pendown()turtle.circle(5)turtle.end_fill()turtle.penup()turtle.color((0,0,0),(0,0,0))turtle.goto(10,240)turtle.begin_fill()turtle.pendown()turtle.circle(3)turtle.end_fill()turtle.penup()turtle.end_fill()turtle.color((0,0,0),(0,0,0))turtle.goto(-10,240)turtle.begin_fill()turtle.pendown()turtle.circle(3)turtle.end_fill()turtle.penup()turtle.color((0,0,0),(60,80,30))turtle.goto(-120,150)turtle.pendown()turtle.seth(30)turtle.begin_fill()a=0.3for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.06        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.06        turtle.lt(3)        turtle.fd(a)turtle.end_fill()turtle.penup()turtle.goto(120,150)turtle.pendown()turtle.seth(-30)a=0.3turtle.begin_fill()for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.06        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.06        turtle.lt(3)        turtle.fd(a)turtle.penup()turtle.end_fill()turtle.goto(-120,-160)turtle.pendown()turtle.seth(-210)turtle.begin_fill()a=0.5for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.03        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.03        turtle.lt(3)        turtle.fd(a) turtle.penup()turtle.end_fill()turtle.goto(120,-160)turtle.pendown()turtle.seth(210)turtle.begin_fill()a=0.5for i in range(120):    if 0<=i<30 or 60<=i<=90:        a=a+0.03        turtle.lt(3)        turtle.fd(a)    else:        a=a-0.03        turtle.lt(3)        turtle.fd(a)turtle.end_fill()turtle.penup()turtle.goto(0,-200)turtle.seth(0)turtle.pendown()turtle.begin_fill()turtle.fd(10)turtle.seth(-105)turtle.fd(30)turtle.seth(105)turtle.fd(30)turtle.seth(0)turtle.fd(10)turtle.end_fill()turtle.hideturtle()turtle.mainloop()123

結果:

五角圓環
import turtle as tt.goto(100,0)for i in range(50):    t.left(80)    t.fd(100)    t.left(135)    t.fd(105)1234567

結果:

大風車
import turtle as tt.goto(100,0)for i in range(100):    t.left(80)    t.fd(100)    t.left(135)    t.fd(165)    t.left(125)    t.fd(115)123456789

結果:

3
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 大資料:ELK技術棧詳解