Guest User

Untitled

a guest
Nov 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #Polygon Art! Make a polygon, rotate it!
  2.  
  3. from random import *
  4.  
  5. def getShape():
  6. vertexes = []
  7. for i in range(randint(3,5)):
  8. vertexes.append([randint(0,30)+20,randint(-30,30)])
  9. return vertexes
  10.  
  11.  
  12. def makeArt(x,y):
  13.  
  14. #Shape 1, to go underneath
  15. s = getShape()
  16. noStroke()
  17. pushMatrix()
  18. translate(x,y)
  19. h = randint(0,255)
  20. a = randint(150,255)
  21. fill(h,255,200,a)
  22. stroke(h,255,255,a)
  23. strokeWeight(2)
  24.  
  25. m = randint(6,10)
  26. for i in range(m):
  27. rotate(radians(360/m))
  28. beginShape()
  29. for j in range(len(s)):
  30. vertex(s[j][0],s[j][1])
  31. endShape(CLOSE)
  32. popMatrix()
  33.  
  34. #Shape 2, put on top of shape 1
  35. s2 = getShape()
  36. pushMatrix()
  37. translate(x,y)
  38. h2 = randint(0,255)
  39. a2 = randint(150,255)
  40. fill(h2,255,200,a2)
  41. stroke(h2,255,255,a2)
  42. strokeWeight(2)
  43. m2 = randint(6,8)
  44. for i in range(m2):
  45. rotate(radians(360/m2))
  46. beginShape()
  47. for j in range(len(s2)):
  48. vertex(s2[j][0],s2[j][1])
  49. endShape(CLOSE)
  50. popMatrix()
  51.  
  52.  
  53.  
  54. def setup():
  55. size(600,600)
  56. colorMode(HSB)
  57.  
  58. def draw():
  59. background(50)
  60. for x in range(5):
  61. for y in range(5):
  62. makeArt((x*120)+60,(y*120)+60)
  63.  
  64. noLoop()
Add Comment
Please, Sign In to add comment