1. 程式人生 > >python畫iPhone手機,這種操作有幾個人見過?

python畫iPhone手機,這種操作有幾個人見過?

雖然我用不起蘋果手機,但我可以用python畫出來!

環境準備

執行平臺: Windows

Python版本: Python 3.6.4

IDE: Pycharm或自帶的IDLE

繪製程式碼

如果你感覺學不會?莫慌,小編推薦大家加入群,

前面548中間377後面875,群裡有志同道合的小夥伴,

互幫互助,還可以拿到許多視訊教程!

import turtle

def round_rectangle(length,high,cor_angle,cor_rad):

for i in range(2):

turtle.fd(high)

turtle.circle(cor_rad,cor_angle)

turtle.fd(length)

turtle.circle(cor_rad,cor_angle)

def main():

turtle.setup(1300,800,0,0)#啟動視窗的大小,左上角右上角座標

pythonsize=2

turtle.pensize(pythonsize)#執行寬度

turtle.speed(10)

turtle.seth(90)#啟動時執行的方向(角度)

#最外邊框

turtle.pencolor("#8E8e8e")

turtle.penup()

turtle.goto(202,-202)

turtle.pendown()

round_rectangle(244,484,90,30)

#填充

turtle.penup()

turtle.goto(200,-200)

turtle.pendown()

turtle.begin_fill()

turtle.color("#F0F0F0")

round_rectangle(240,480,90,30)

turtle.end_fill()

#手機屏

turtle.pencolor("black")#(#3000440)

turtle.penup()

turtle.goto(185,-150)

turtle.pendown()

turtle.begin_fill()

turtle.color("black")

round_rectangle(270,380,90,0)

turtle.end_fill()

#聽筒

turtle.penup()

turtle.goto(80,265)

turtle.pendown()

turtle.begin_fill()

turtle.color("#9d9d9d")

round_rectangle(60,4,90,1)

turtle.end_fill()

#聽筒上面的小黑

turtle.penup()

turtle.goto(55,290)

turtle.pendown()

turtle.begin_fill()

turtle.color("#3c3c3c")

turtle.circle(4,360)

turtle.end_fill()

#攝像頭

turtle.penup()

turtle.goto(0,265)

turtle.pendown()

turtle.begin_fill()

turtle.color("#3c3c3c")

turtle.circle(6,360)

turtle.end_fill()

#home健

turtle.pencolor("#9d9d9d")#(#3000440)

turtle.penup()

turtle.goto(75,-185)

turtle.pendown()

turtle.circle(25,360)

#home健圖案

turtle.pencolor("#9d9d9d")#(#3000440)

turtle.penup()

turtle.goto(60,-190)

turtle.pendown()

turtle.hideturtle()

main()

執行結果:

縮圖:

大聲告訴我,這種教程你以前見過嗎?