Requires

Provides

Rectangle.js

Rectangles with rounded corners

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30
  11. 31
  12. 32
  13. 33
  14. 34
  15. 35
  16. 36
  17. 37
  18. 38
  19. 39
  20. 40
  21. 41
  22. 42
  23. 43
  24. 44
  25. 45
  26. 46
  27. 47
  28. 48
  29. 49
  30. 50
  31. 51
  32. 52
  33. 53
  34. 54
  35. 55
  36. 56
  37. 57
  38. 58
  39. 59
  40. 60
  41. 61
  42. 62
  43. 63
  44. 64
  45. 65
  46. 66
  47. 67
  48. 68
ART.Shape.Rectangle = new Class({ Extends: ART.Shape, draw: function(width, height, radius) { var path = new ART.Path; if (!radius){ path.move(0, 0).line(width, 0).line(0, height).line(-width, 0).line(0, -height); } else { if (typeof radius == 'number') radius = [radius, radius, radius, radius]; var tl = radius[0], tr = radius[1], br = radius[2], bl = radius[3]; if (tl < 0) tl = 0; if (tr < 0) tr = 0; if (bl < 0) bl = 0; if (br < 0) br = 0; path.move(0, tl); if (width < 0) path.move(width, 0); if (height < 0) path.move(0, height); if (tl > 0) path.arc(tl, -tl); path.line(Math.abs(width) - (tr + tl), 0); if (tr > 0) path.arc(tr, tr); path.line(0, Math.abs(height) - (tr + br)); if (br > 0) path.arc(-br, br); path.line(- Math.abs(width) + (br + bl), 0); if (bl > 0) path.arc(-bl, -bl); path.line(0, - Math.abs(height) + (bl + tl)); } return this.parent(path); }, render: function(context) { var radius = context.radius; if (radius && radius.length == 4) radius = [radius[0], radius[2], radius[3], radius[1]] return this.draw(context.size.width, context.size.height, radius) } });