当前位置:   article > 正文

python好看图案的编程代码,python简单图案代码小熊_python绘图代码

python绘图代码

大家好,本文将围绕python好看图案的编程代码展开说明,python简单图案代码小熊是一个很多人都想弄明白的事情,想搞清楚python简单图案代码turtle需要先了解以下几个事情。

Source code download: 本文相关源码

1、python画迪斯科灯

  1. import turtle
  2. import math
  3. import random
  4. #color = ['green','red','blue','yellow','orange','pink']
  5. pen = turtle.Turtle()
  6. turtle.colormode(255)
  7. rr = 3
  8. theta = 0
  9. pi = 3.1415926
  10. pen.pensize(5)
  11. pen.speed(0)
  12. pen.left(90)
  13. for j in range(60):
  14. r = random.randint(0,255)
  15. g = random.randint(0,255)
  16. b = random.randint(0,255)
  17. pen.penup()
  18. pen.goto(0,0)
  19. pen.down()
  20. #pen.pencolor(color[j%6])
  21. pen.pencolor((r,g,b))
  22. pen.penup()
  23. pen.goto(60*math.sin(2*pi/60*j),60*math.cos(2*pi/60*j))
  24. pen.down()
  25. #pen.reset()
  26. #pen.left(6)
  27. pen.forward(random.randint(20,80))
  28. pen.setheading(90)
  29. pen.right(6*j)
  30. #theta = 6 * j
  31. turtle.done()

 2、Python画随机雨点

  1. import turtle
  2. import math
  3. import random
  4. pen = turtle.Turtle()
  5. turtle.colormode(255)
  6. rr = 20
  7. #theta = 0
  8. #pi = 3.1415926
  9. pen.pensize(5)
  10. pen.speed(0)
  11. r = 100
  12. g = 100
  13. b = 150
  14. dd0 = 20
  15. dd = 30
  16. for j in range(20):
  17. rr = 20
  18. r = 100
  19. g = 100
  20. b = 150
  21. dd0 = 20
  22. dd = 30
  23. x = random.randint(-300,300)
  24. y = random.randint(-300,300)
  25. for i in range(10):
  26. pen.color((r,g,b))
  27. pen.penup()
  28. #pen.goto(0,dd0+dd)
  29. pen.goto(x,y+dd0-2*(11-i))
  30. pen.down()
  31. pen.dot(rr)
  32. #dd = dd - 3
  33. rr = rr -2
  34. r = r + 6
  35. b = b + 6
  36. turtle.done()

 3、Python画五彩螺旋

  1. from turtle import *
  2. colors = ['red', 'purple', 'blue', 'green', 'yellow', 'orange']
  3. for x in range(360):
  4. pencolor(colors[x % 6])
  5. width(x / 100 + 1)
  6. forward(x)
  7. left(59)
  8. speed(0)
  9. done()

五彩螺旋2

  1. import turtle
  2. color = ['green','red','blue','yellow','orange','pink']
  3. pen = turtle.Turtle()
  4. rr = 3
  5. pen.pensize(3)
  6. pen.speed(0)
  7. for j in range(20):
  8. for i in range(5):
  9. rr = rr + 2
  10. pen.pencolor(color[i])
  11. pen.forward(rr)
  12. pen.left(36) # 61 84 6
  13. pen.pencolor(color[5])
  14. pen.forward(rr)
  15. pen.left(36)
  16. rr = rr + 2
  17. turtle.done()

 

文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树首页概览420863 人正在系统学习中
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/622459
推荐阅读
相关标签
  

闽ICP备14008679号