We Recommend

Learning Python Learning Python
The authors of Learning Python show you enough essentials of the Python scripting language to enable you to begin solving problems right away, then reveal more powerful aspects of the language one at a time. This approach is sure to appeal to programmers and system administrators who have urgent problems and a preference for learning by semi-guided experimentation.


Posted By

n3x on 06/20/07


Tagged

nodebox


Versions (?)


NodeBox test: arrows


Published in: Python 


I was just asked how I did this http://www.vimeo.com/clip:218013 so here goes ...

  1. import math
  2.  
  3. width, height = 400, 300
  4.  
  5. size(width, height)
  6. speed(8)
  7.  
  8. def setup():
  9. global frame
  10. frame = 1
  11. global dots
  12. dots = [[50*x + 25, 50*y + 25, (y - x)*10.0] for x in xrange(8) for y in xrange(6)]
  13.  
  14. def stepDots():
  15. global dots
  16. for d in dots:
  17. d[2] += (d[0] + d[1])*0.01
  18.  
  19. def draw():
  20. global frame
  21. global distort
  22. global dots
  23.  
  24. stepDots()
  25. nofill()
  26. strokewidth(5)
  27. colormode(HSB)
  28. for d in dots:
  29. push()
  30. rotate(d[2])
  31. h = math.sin(math.radians(d[2])/5.0)*20.0
  32. stroke(math.sin(h)*0.1 + (math.sin(frame/48.0)*0.4 + 0.5), 0.7, 0.5, 1 - abs(h/15.0))
  33. scale(h/1.3)
  34. #rect(d[0], d[1], 10, 10)
  35. arrow(d[0], d[1], 20)
  36. pop()
  37.  
  38. frame += 1

Report this snippet 

You need to login to post a comment.