程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2023-05(3)

用python画一个少数名族风情的圆

发布于2019-08-22 16:40     阅读(1439)     评论(0)     点赞(23)     收藏(5)


 

 

  1. import turtle
  2. def jump(x, y):
  3. turtle.penup()
  4. turtle.goto(x, y)
  5. turtle.pendown()
  6. def forward(l):
  7. turtle.forward(l)
  8. def right(a):
  9. turtle.right(a)
  10. def pause():
  11. turtle.done()
  12. def begin_fill():
  13. turtle.begin_fill()
  14. def fill_color(color):
  15. turtle.fillcolor(color)
  16. def end_fill():
  17. turtle.end_fill()
  18. def set_pencolor(*color):
  19. if len(color) == 3:
  20. # 说明是 rgb, 这里手动除以 3
  21. r, g, b = color
  22. r = r / 255
  23. g = g / 255
  24. b = b / 255
  25. turtle.color(r, g, b)
  26. else:
  27. turtle.color(*color)
  28. def set_pensize(width):
  29. turtle.pensize(width)
  30. def hide():
  31. turtle.hideturtle()
  32. from gua import *
  33. import math
  34. import random
  35. def log(*args, **kwargs):
  36. print(*args, **kwargs)
  37. def color():
  38. j = 0
  39. color = '#'
  40. se = '0123456789ABCDEF'
  41. while j < 6:
  42. n = random.randint(0, 15)
  43. color = color + se[n]
  44. j = j + 1
  45. log(color)
  46. return color
  47. def circle(x, y):
  48. i = 0
  49. l = 1 * math.pi * 100 / 180
  50. while i < 360:
  51. jump(x, y)
  52. colo = color()
  53. set_pencolor(colo)
  54. begin_fill()
  55. fill_color(colo)
  56. forward(100)
  57. right(90)
  58. forward(l)
  59. right(90)
  60. forward(100)
  61. right(180)
  62. right(1)
  63. end_fill()
  64. i = i + 1
  65. circle(0, 0)
  66. pause()
标题


所属网站分类: 技术文章 > 博客

作者:hghgh

链接:https://www.pythonheidong.com/blog/article/52978/2a728bbd87fb4a67d59f/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

23 0
收藏该文
已收藏

评论内容:(最多支持255个字符)