python-turtle库,心得随心画~~

Posted zhenie

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python-turtle库,心得随心画~~相关的知识,希望对你有一定的参考价值。

画画篮球场——→

代码如下:

技术图片
  1 import turtle
  2 turtle.pu()
  3 turtle.left(90)
  4 turtle.fd(250)
  5 turtle.left(90)
  6 turtle.fd(70)
  7 turtle.left(20)
  8 turtle.pd()
  9 turtle.pensize(3)
 10 
 11 turtle.color(gold,pink)
 12 turtle.begin_fill()
 13 turtle.fd(150)          #三分圈
 14 turtle.circle(200,55)
 15 turtle.left(5)
 16 turtle.circle(250,10)
 17 turtle.circle(200,10)
 18 turtle.left(5)
 19 turtle.circle(200,20)
 20 turtle.right(5)
 21 turtle.circle(180,20)
 22 turtle.circle(400,20)
 23 turtle.circle(600,16)
 24 turtle.right(5)
 25 turtle.circle(600,20)
 26 turtle.left(12)
 27 turtle.fd(150)
 28 turtle.left(113)
 29 turtle.pencolor(purple)
 30 turtle.fd(602)
 31 turtle.end_fill()
 32 
 33 
 34 turtle.fd(25)           #边界
 35 turtle.left(65)
 36 turtle.fd(450)
 37 turtle.left(110)
 38 turtle.fd(664)
 39 turtle.left(74)
 40 turtle.fd(500)
 41 turtle.left(111.1)
 42 turtle.fd(245)
 43 
 44 turtle.pencolor(orange)          #小圆
 45 turtle.left(60)
 46 turtle.fd(360)
 47 turtle.circle(-200,35)
 48 turtle.right(5)
 49 turtle.circle(-115,35)
 50 turtle.circle(-60,90)
 51 turtle.right(5)
 52 turtle.left(5)
 53 turtle.circle(-100,23)
 54 turtle.left(10)
 55 turtle.fd(325)
 56 turtle.right(62)
 57 turtle.fd(210)
 58 
 59 turtle.right(120)       #右抢篮板分位块
 60 turtle.fd(105)
 61 turtle.left(120)
 62 turtle.fd(17)
 63 turtle.right(120)
 64 turtle.fd(30)
 65 turtle.right(60)
 66 turtle.fd(17)
 67 turtle.left(60)
 68 
 69 turtle.fd(60)            #右抢篮板分位线1
 70 turtle.left(120)
 71 turtle.fd(17)
 72 turtle.fd(-17)
 73 turtle.right(120)
 74 
 75 turtle.fd(60)             #右线2
 76 turtle.left(120)
 77 turtle.fd(17)
 78 turtle.fd(-17)
 79 turtle.right(120)
 80 
 81 turtle.fd(60)             #右线3
 82 turtle.left(120)
 83 turtle.fd(17)
 84 turtle.fd(-17)
 85 turtle.right(120)
 86 
 87 turtle.fd(45)             #罚球线
 88 turtle.right(70)
 89 turtle.fd(183)
 90 turtle.right(108)
 91 
 92 turtle.fd(35)              #左线3
 93 turtle.left(120)
 94 turtle.fd(17)
 95 turtle.fd(-17)
 96 turtle.right(120)
 97 
 98 turtle.fd(50)              #左线2
 99 turtle.left(120)
100 turtle.fd(17)
101 turtle.fd(-17)
102 turtle.right(120)
103 
104 turtle.fd(50)              #左线1
105 turtle.left(120)
106 turtle.fd(17)
107 turtle.fd(-17)
108 turtle.right(120)
109 
110 turtle.fd(50)               #左抢篮板分位块
111 turtle.left(120)
112 turtle.fd(17)
113 turtle.right(120)
114 turtle.fd(30)
115 turtle.right(60)
116 turtle.fd(17)
117 turtle.left(60)
118 turtle.fd(103)
119 
120 turtle.pensize(2)           #左半柱
121 turtle.right(62)
122 turtle.fd(80)
123 turtle.pencolor(purple)
124 turtle.left(130)
125 turtle.fd(90)
126 turtle.right(130)
127 turtle.fd(10)
128 turtle.left(130)
129 turtle.fd(50)
130 
131 
132 turtle.left(90)             #篮板
133 turtle.fd(45)
134 turtle.right(30)
135 turtle.fd(60)
136 turtle.right(60)
137 turtle.fd(80)
138 turtle.right(120)
139 turtle.fd(120)
140 turtle.right(60)
141 turtle.fd(80)
142 turtle.right(120)
143 turtle.fd(60)
144 
145 
146 turtle.color(purple,pink)     #瞄准框
147 turtle.begin_fill()
148 turtle.right(60)
149 turtle.fd(10)
150 turtle.left(60)
151 turtle.fd(20)
152 turtle.right(60)
153 turtle.fd(30)
154 turtle.right(120)
155 turtle.fd(40)
156 turtle.right(60)
157 turtle.fd(30)
158 turtle.right(120)
159 turtle.fd(20)
160 turtle.end_fill()
161 
162 turtle.left(10)             #篮筐
163 turtle.circle(80,50)
164 turtle.left(110)
165 turtle.circle(50,60)
166 turtle.left(5)
167 turtle.circle(50,28)
168 
169 turtle.left(180)            #篮网
170 turtle.fd(70)
171 turtle.right(115)
172 turtle.fd(55)
173 turtle.right(160)
174 turtle.fd(70)
175 turtle.left(170)
176 turtle.fd(68)
177 turtle.left(170)
178 turtle.fd(62)
179 turtle.left(160)
180 turtle.fd(60)
181 turtle.right(170)
182 turtle.fd(60)
183 turtle.left(160)
184 turtle.fd(55)
185 turtle.left(160)
186 turtle.fd(63)
187 turtle.left(115)
188 turtle.fd(25)
189 turtle.left(73)
190 turtle.fd(55)
191 
192 turtle.right(75)            #右半柱
193 turtle.fd(65)
194 turtle.right(92)
195 turtle.fd(65)
196 turtle.left(70)
197 turtle.fd(8)
198 turtle.right(70)
199 turtle.fd(103)
200 turtle.hideturtle()
简约篮球场

运行结果如下:

技术图片

 

 觉得好玩就试一下吧!!!

以上是关于python-turtle库,心得随心画~~的主要内容,如果未能解决你的问题,请参考以下文章

python-turtle-画雪花-2种方法及效果的详解

Python-turtle库知识小结(python绘图工具)

python-turtle绘制雪容融,已打包成exe可直接运行

开发心得

分享知识-快乐自己:初识 Hibernate 概念片

前端随心记---------React简介