鱼C论坛

 找回密码
 立即注册
查看: 2896|回复: 8

[作品展示] turtle画图

[复制链接]
发表于 2020-4-8 17:51:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 hjg 于 2021-3-26 19:14 编辑
  1. from turtle import*
  2. from random import*
  3. setup(5000,3300,10,10)
  4. #设置初始位置
  5. penup()
  6. goto(-250,250)
  7. pendown()
  8. #画布布置
  9. #1
  10. fillcolor("midnightblue")
  11. begin_fill()
  12. fd(330)
  13. right(90)
  14. fd(50)
  15. right(90)
  16. fd(330)
  17. right(90)
  18. fd(50)
  19. end_fill()
  20. right(180)
  21. fd(50)
  22. #2
  23. fillcolor("Navy")
  24. begin_fill()
  25. fd(80)
  26. left(90)
  27. fd(330)
  28. left(90)
  29. fd(80)
  30. end_fill()
  31. left(180)
  32. fd(80)
  33. #5
  34. fillcolor("BlueViolet")
  35. begin_fill()
  36. fd(75)
  37. right(90)
  38. fd(330)
  39. right(90)
  40. fd(75)
  41. end_fill()
  42. right(180)
  43. fd(75)
  44. #8
  45. fillcolor("DeepPink")
  46. begin_fill()
  47. fd(65)
  48. left(90)
  49. fd(330)
  50. left(90)
  51. fd(65)
  52. end_fill()
  53. left(180)
  54. fd(65)
  55. #10
  56. fillcolor("Coral")
  57. begin_fill()
  58. fd(60)
  59. right(90)
  60. fd(330)
  61. right(90)
  62. fd(60)
  63. end_fill()
  64. right(180)
  65. fd(60)
  66. #12
  67. fillcolor("Moccasin")
  68. begin_fill()
  69. fd(40)
  70. left(90)
  71. fd(330)
  72. left(90)
  73. fd(40)
  74. end_fill()
  75. left(180)
  76. fd(40)
  77. #14
  78. fillcolor("NavajoWhite")
  79. begin_fill()
  80. fd(70)
  81. right(90)
  82. fd(330)
  83. right(90)
  84. fd(70)
  85. end_fill()
  86. right(180)
  87. fd(70)
  88. #画星星
  89. pencolor("white")
  90. pensize(1)
  91. for i in range(330):
  92.     a=randint(-250,90)
  93.     b=randint(-190,350)
  94.     pencolor("white")
  95.     penup()
  96.     goto(a,b)
  97.     pendown()
  98.     fd(2)
  99. #画房子
  100. penup()
  101. goto(-250,10)
  102. pendown()
  103. pensize(6)
  104. pencolor("black")
  105. fillcolor("black")
  106. begin_fill()
  107. seth(0)
  108. fd(100)
  109. seth(45)
  110. fd(20)
  111. right(90)
  112. fd(9)
  113. right(95)
  114. fd(23)
  115. seth(270)
  116. fd(70)
  117. seth(0)
  118. fd(75)
  119. right(90)
  120. fd(50)
  121. left(90)
  122. fd(73)
  123. right(90)
  124. fd(43)
  125. seth(0)
  126. fd(78)
  127. seth(270)
  128. fd(30)
  129. seth(180)
  130. fd(330)
  131. seth(90)
  132. fd(192)
  133. end_fill()

  134. #画电线杆
  135. #1
  136. penup()
  137. goto(-100,-60)
  138. pendown()
  139. pensize(10)
  140. seth(90)
  141. fd(240)
  142. seth(270)
  143. fd(10)
  144. seth(0)
  145. fd(32)
  146. seth(180)
  147. fd(53)
  148. seth(0)
  149. fd(24)
  150. seth(270)
  151. penup()
  152. fd(77)
  153. pendown()
  154. seth(0)
  155. fd(60)
  156. seth(180)
  157. fd(112)
  158. penup()
  159. seth(0)
  160. fd(15)
  161. pendown()
  162. seth(270)
  163. fd(3)
  164. #2
  165. penup()
  166. goto(-37,-110)
  167. pendown()
  168. pensize(7)
  169. seth(90)
  170. fd(160)
  171. penup()
  172. seth(270)
  173. fd(30)
  174. pendown()
  175. seth(0)
  176. fd(28)
  177. seth(180)
  178. fd(53)
  179. penup()
  180. seth(90)
  181. fd(16)
  182. seth(0)
  183. fd(13)
  184. pendown()
  185. fd(28)
  186. #3
  187. penup()
  188. goto(43,-153)
  189. pendown()
  190. pensize(5)
  191. seth(90)
  192. fd(148)
  193. penup()
  194. seth(270)
  195. fd(10)
  196. pendown()
  197. seth(180)
  198. fd(10)
  199. seth(0)
  200. fd(14)
  201. penup()
  202. seth(270)
  203. fd(10)
  204. pendown()
  205. seth(180)
  206. fd(29)
  207. #画电线
  208. #1
  209. seth(0)
  210. fd(10)
  211. seth(146)
  212. fd(79)
  213. #2
  214. penup()
  215. goto(44,-22)
  216. seth(160)
  217. pendown()
  218. fd(111)
  219. #3
  220. penup()
  221. goto(42,-10)
  222. seth(148)
  223. pendown()
  224. fd(83)
  225. #4
  226. penup()
  227. goto(-249,240)
  228. pendown()
  229. seth(332)
  230. fd(159)
  231. #5
  232. penup()
  233. goto(-248,148)
  234. pendown()
  235. seth(341)
  236. fd(187)
  237. #6
  238. seth(302)
  239. fd(57)
  240. #7
  241. penup()
  242. goto(-40,33)
  243. pendown()
  244. seth(166)
  245. fd(56)
  246. #8
  247. penup()
  248. goto(-36,33)
  249. seth(103)
  250. pendown()
  251. fd(71)
  252. #9
  253. penup()
  254. goto(-140,85)
  255. pendown()
  256. seth(251)
  257. fd(99)
  258. #画草
  259. #1
  260. pencolor("black")
  261. for i in range(30):
  262.     pensize(2)
  263.     n=randint(-45,-23)
  264.     m=randint(0,180)
  265.     k=randint(10,25)
  266.     penup()
  267.     goto(n,-115)
  268.     pendown()
  269.     seth(m)
  270.     fd(k)
  271. #2
  272. for i in range(20):
  273.     pensize(2)
  274.     j=randint(12,65)
  275.     m=randint(0,180)
  276.     k=randint(10,33)
  277.     penup()
  278.     goto(j,-157)
  279.     pendown()
  280.     seth(m)
  281.     fd(k)
  282. #画流星
  283. pencolor("white")
  284. for i in range(8):
  285.     pensize(1)
  286.     c=randint(-250,130)
  287.     d=randint(50,290)
  288.     x=randint(70,80)
  289.     y=randint(210,230)
  290.     penup()
  291.     goto(c,d)
  292.     pendown()
  293.     seth(y)
  294.     fd(x)
  295. ##############
  296. #画布2布置
  297. penup()
  298. goto(80,250)
  299. pendown()
  300. fillcolor("darkorange")
  301. begin_fill()
  302. seth(0)
  303. fd(300)
  304. seth(270)
  305. fd(220)
  306. seth(180)
  307. fd(300)
  308. seth(90)
  309. fd(220)
  310. end_fill()
  311. #
  312. penup()
  313. goto(380,30)
  314. pendown()
  315. fillcolor("SandyBrown")
  316. begin_fill()
  317. seth(270)
  318. fd(220)
  319. seth(180)
  320. fd(300)
  321. seth(90)
  322. fd(220)
  323. end_fill()
  324. #画夕阳
  325. penup()
  326. goto(333,221)
  327. pendown()
  328. fillcolor("LightYellow")
  329. begin_fill()
  330. circle(18,360)
  331. end_fill()
  332. #画房子
  333. pencolor("black")
  334. penup()
  335. goto(380,199)
  336. pendown()
  337. fillcolor("black")
  338. begin_fill()
  339. seth(209)
  340. fd(213)
  341. seth(270)
  342. fd(30)
  343. seth(0)
  344. fd(46)
  345. seth(270)
  346. fd(65)
  347. seth(180)
  348. fd(69)
  349. seth(270)
  350. fd(63)
  351. seth(0)
  352. fd(69)
  353. seth(270)
  354. fd(30)
  355. seth(180)
  356. fd(71)
  357. seth(270)
  358. fd(30)
  359. seth(0)
  360. fd(39)
  361. seth(270)
  362. fd(27)
  363. seth(180)
  364. fd(86)
  365. seth(123)
  366. fd(54)
  367. seth(255)
  368. fd(51)
  369. seth(270)
  370. fd(40)
  371. seth(0)
  372. fd(299)
  373. seth(90)
  374. fd(388)
  375. end_fill()
  376. #画电线杆
  377. #1
  378. penup()
  379. goto(103,-154)
  380. pendown()
  381. pensize(5)
  382. seth(90)
  383. fd(148)
  384. penup()
  385. seth(270)
  386. fd(10)
  387. pendown()
  388. seth(180)
  389. fd(15)
  390. seth(0)
  391. fd(24)
  392. penup()
  393. seth(270)
  394. fd(10)
  395. pendown()
  396. seth(180)
  397. fd(29)
  398. #2
  399. penup()
  400. goto(140,-154)
  401. pendown()
  402. pensize(7)
  403. seth(90)
  404. fd(220)
  405. penup()
  406. seth(270)
  407. fd(40)
  408. pendown()
  409. seth(0)
  410. fd(28)
  411. seth(180)
  412. fd(53)
  413. penup()
  414. seth(90)
  415. fd(16)
  416. seth(0)
  417. fd(13)
  418. pendown()
  419. fd(28)
  420. #画电线
  421. pensize(3)
  422. penup()
  423. seth(180)
  424. fd(6)
  425. pendown()
  426. seth(39)
  427. fd(54)
  428. #*
  429. penup()
  430. seth(0)
  431. fd(18)
  432. seth(270)
  433. fd(9)
  434. pendown()
  435. seth(216)
  436. fd(69)
  437. #**
  438. penup()
  439. seth(270)
  440. fd(5)
  441. seth(180)
  442. fd(21)
  443. pendown()
  444. seth(244)
  445. fd(61)
  446. #****
  447. penup()
  448. seth(121)
  449. fd(7)
  450. pendown()
  451. seth(69)
  452. fd(75)
  453. ##
  454. penup()
  455. seth(270)
  456. fd(16)
  457. seth(180)
  458. fd(9)
  459. pendown()
  460. seth(228)
  461. fd(55)
  462. #画草
  463. for i in range(26):
  464.     pensize(2)
  465.     p=randint(123,172)
  466.     m=randint(0,180)
  467.     l=randint(10,30)
  468.     penup()
  469.     goto(p,-155)
  470.     pendown()
  471.     seth(m)
  472.     fd(l)

  473. #画鸟
  474. penup()
  475. pensize(2)
  476. goto(269,179)
  477. pendown()
  478. seth(25)
  479. fd(30)
  480. penup()
  481. seth(205)
  482. fd(15)
  483. pendown()
  484. seth(61)
  485. fd(30)
  486. penup()
  487. seth(241)
  488. fd(30)
  489. pendown()
  490. seth(177)
  491. fd(28)
  492. #
  493. penup()
  494. pensize(2)
  495. goto(138,151)
  496. pendown()
  497. seth(25)
  498. fd(26)
  499. penup()
  500. seth(205)
  501. fd(13)
  502. pendown()
  503. seth(61)
  504. fd(24)
  505. penup()
  506. seth(241)
  507. fd(24)
  508. pendown()
  509. seth(177)
  510. fd(22)
  511. #
  512. penup()
  513. pensize(2)
  514. goto(214,222)
  515. pendown()
  516. seth(20)
  517. fd(18)
  518. penup()
  519. seth(200)
  520. fd(9)
  521. pendown()
  522. seth(61)
  523. fd(12)
  524. penup()
  525. seth(241)
  526. fd(12)
  527. pendown()
  528. seth(177)
  529. fd(16)
  530. #
  531. penup()
  532. pensize(2)
  533. goto(162,199)
  534. pendown()
  535. seth(25)
  536. fd(24)
  537. penup()
  538. seth(205)
  539. fd(12)
  540. pendown()
  541. seth(61)
  542. fd(35)
  543. penup()
  544. seth(241)
  545. fd(35)
  546. pendown()
  547. seth(177)
  548. fd(38)
  549. #
  550. penup()
  551. pensize(2)
  552. goto(105,114)
  553. pendown()
  554. seth(25)
  555. fd(22)
  556. penup()
  557. seth(205)
  558. fd(11)
  559. pendown()
  560. seth(61)
  561. fd(21)
  562. penup()
  563. seth(241)
  564. fd(21)
  565. pendown()
  566. seth(177)
  567. fd(24)
  568. #
  569. penup()
  570. pensize(2)
  571. goto(85,59)
  572. pendown()
  573. seth(20)
  574. fd(18)
  575. penup()
  576. seth(200)
  577. fd(9)
  578. pendown()
  579. seth(61)
  580. fd(12)
  581. penup()
  582. seth(241)
  583. fd(12)
  584. pendown()
  585. seth(177)
  586. fd(16)
  587. #
  588. penup()
  589. pensize(2)
  590. goto(92,236)
  591. pendown()
  592. seth(20)
  593. fd(18)
  594. penup()
  595. seth(200)
  596. fd(9)
  597. pendown()
  598. seth(61)
  599. fd(12)
  600. penup()
  601. seth(241)
  602. fd(12)
  603. pendown()
  604. seth(177)
  605. fd(16)
  606. #
  607. penup()
  608. pensize(2)
  609. goto(174,82)
  610. pendown()
  611. seth(20)
  612. fd(18)
  613. penup()
  614. seth(200)
  615. fd(9)
  616. pendown()
  617. seth(61)
  618. fd(12)
  619. penup()
  620. seth(241)
  621. fd(12)
  622. pendown()
  623. seth(177)
  624. fd(16)
  625. #
  626. penup()
  627. pensize(2)
  628. goto(210,120)
  629. pendown()
  630. seth(20)
  631. fd(18)
  632. penup()
  633. seth(200)
  634. fd(9)
  635. pendown()
  636. seth(61)
  637. fd(12)
  638. penup()
  639. seth(241)
  640. fd(12)
  641. pendown()
  642. seth(177)
  643. fd(16)
  644. #
  645. penup()
  646. pensize(2)
  647. goto(94,186)
  648. pendown()
  649. seth(20)
  650. fd(18)
  651. penup()
  652. seth(200)
  653. fd(9)
  654. pendown()
  655. seth(61)
  656. fd(12)
  657. penup()
  658. seth(241)
  659. fd(12)
  660. pendown()
  661. seth(177)
  662. fd(16)
  663. ###3
  664. penup()
  665. goto(400,400)
  666. pendown()
复制代码

评分

参与人数 2荣誉 +2 鱼币 +4 贡献 +2 收起 理由
WangJS + 2 + 3 + 2 很好,我来评分
乘号 + 1 鼓励一下

查看全部评分

本帖被以下淘专辑推荐:

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-4-8 17:56:02 | 显示全部楼层
刚学画图的时候画的
0.PNG
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-8 18:22:12 | 显示全部楼层
不错不错
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-8 18:23:16 | 显示全部楼层
我加到我的淘贴(用Python画画)里去了

PS:下次记得用代码格式发代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-8 21:43:03 | 显示全部楼层
不错

建议加个代码格式

就是 工具栏的 “<>”

  1. 这是效果
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-6-8 20:43:34 | 显示全部楼层
呕吼
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-8-3 22:00:26 | 显示全部楼层
不过要等很久
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-3-26 19:21:50 | 显示全部楼层
liuzhengyuan 发表于 2020-4-8 21:43
不错

建议加个代码格式

兄dei 你这个名字昵称的GIF是怎么制作出来的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-4-3 19:55:33 | 显示全部楼层
hjg 发表于 2021-3-26 19:21
兄dei 你这个名字昵称的GIF是怎么制作出来的

改个性签名变成图片就可以了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-7 19:45

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表