Requires

Provides

Star.js

A star with variable number of edges

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 22
  2. 23
  3. 24
  4. 25
  5. 26
  6. 27
  7. 28
  8. 29
  9. 30
  10. 31
  11. 32
  12. 33
  13. 34
  14. 35
  15. 36
  16. 37
  17. 38
  18. 39
  19. 40
  20. 41
  21. 42
  22. 43
  23. 44
  24. 45
  25. 46
  26. 47
  27. 48
  28. 49
  29. 50
  30. 51
  31. 52
  32. 53
  33. 54
  34. 55
  35. 56
  36. 57
  37. 58
ART.Shape.Star = new Class({ Extends: ART.Shape, properties: ['width', 'height', 'starRays', 'starRadius', 'starOffset'], draw: function(width, height, rays, radius, offset){ if (rays == null) rays = 5; var path = new ART.Path; var outer = width / 2; var angle = Math.PI / rays; offset = angle / (offset || 2.1); if (radius == null) radius = outer *.582; var lx = 0, ly = 0; for (var i = 0; i < rays * 2; i++) { var r = i % 2 ? outer : radius; var x = r * Math.cos(i * angle + offset); var y = r * Math.sin(i * angle + offset); if (i == 0) { path.move(x - lx + outer, y - ly + outer) } else { path.line(x - lx, y - ly); } lx = x; ly = y; } return this.parent(path.close()); } }); !function() { var Properties = { starRays: ['number'], starRadius: ['length', 'percentage'] } }();