API Docs for: 3.13.0
Show:

File: graphics/js/CanvasCircle.js

  1. /**
  2. * <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> implementation of the <a href="Circle.html">`Circle`</a> class.
  3. * `CanvasCircle` is not intended to be used directly. Instead, use the <a href="Circle.html">`Circle`</a> class.
  4. * If the browser lacks <a href="http://www.w3.org/TR/SVG/">SVG</a> capabilities but has
  5. * <a href="http://www.w3.org/TR/html5/the-canvas-element.html">Canvas</a> capabilities, the <a href="Circle.html">`Circle`</a>
  6. * class will point to the `CanvasCircle` class.
  7. *
  8. * @module graphics
  9. * @class CanvasCircle
  10. * @constructor
  11. */
  12. CanvasCircle = function()
  13. {
  14. CanvasCircle.superclass.constructor.apply(this, arguments);
  15. };
  16.  
  17. CanvasCircle.NAME = "circle";
  18.  
  19. Y.extend(CanvasCircle, Y.CanvasShape, {
  20. /**
  21. * Indicates the type of shape
  22. *
  23. * @property _type
  24. * @type String
  25. * @private
  26. */
  27. _type: "circle",
  28.  
  29. /**
  30. * Draws the shape.
  31. *
  32. * @method _draw
  33. * @private
  34. */
  35. _draw: function()
  36. {
  37. var radius = this.get("radius");
  38. if(radius)
  39. {
  40. this.clear();
  41. this.drawCircle(0, 0, radius);
  42. this._closePath();
  43. }
  44. }
  45. });
  46.  
  47. CanvasCircle.ATTRS = Y.merge(Y.CanvasShape.ATTRS, {
  48. /**
  49. * Indicates the width of the shape
  50. *
  51. * @config width
  52. * @type Number
  53. */
  54. width: {
  55. setter: function(val)
  56. {
  57. this.set("radius", val/2);
  58. return val;
  59. },
  60.  
  61. getter: function()
  62. {
  63. return this.get("radius") * 2;
  64. }
  65. },
  66.  
  67. /**
  68. * Indicates the height of the shape
  69. *
  70. * @config height
  71. * @type Number
  72. */
  73. height: {
  74. setter: function(val)
  75. {
  76. this.set("radius", val/2);
  77. return val;
  78. },
  79.  
  80. getter: function()
  81. {
  82. return this.get("radius") * 2;
  83. }
  84. },
  85.  
  86. /**
  87. * Radius of the circle
  88. *
  89. * @config radius
  90. * @type Number
  91. */
  92. radius: {
  93. lazyAdd: false
  94. }
  95. });
  96. Y.CanvasCircle = CanvasCircle;
  97.