python如何绘制iPhone手机图案?(代码示例)


本文摘自php中文网,作者青灯夜游,侵删。

本篇文章给大家带来的内容是介绍python如何绘制iPhone手机图案?(代码示例)。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。

虽然我用不起苹果手机,但我可以用python画出来!

2.jpg

环境准备

运行平台: Windows

Python版本: Python 3.6.4

IDE: Pycharm或自带的IDLE

绘制代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

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()

运行结果:

python画iPhone手机,这种操作有几个人见过?

缩略图:

python画iPhone手机,这种操作有几个人见过?

以上就是python如何绘制iPhone手机图案?(代码示例)的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python抓取网页乱码的原因及解决方法

Python中knn算法(k-近邻算法)的详细介绍(附示例)

Python中json模块和pickle模块的简单介绍(附示例)

Python中对self的理解

Python如何测量脚本运行时间

Python中tuple指什么

Python爬虫获取图片并下载保存至本地

Python 限制函数调用次数

Python数据分析用什么数据库

Python字典怎么使用zip

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...