arc.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2. var Shape = require('../shape');
  3. var bbox = require('../util/bbox');
  4. var Arc =
  5. /*#__PURE__*/
  6. function (_Shape) {
  7. _inheritsLoose(Arc, _Shape);
  8. function Arc() {
  9. return _Shape.apply(this, arguments) || this;
  10. }
  11. var _proto = Arc.prototype;
  12. _proto._initProperties = function _initProperties() {
  13. _Shape.prototype._initProperties.call(this);
  14. this._attrs.canStroke = true;
  15. this._attrs.canFill = true;
  16. this._attrs.type = 'arc';
  17. };
  18. _proto.getDefaultAttrs = function getDefaultAttrs() {
  19. return {
  20. x: 0,
  21. y: 0,
  22. r: 0,
  23. startAngle: 0,
  24. endAngle: Math.PI * 2,
  25. clockwise: false,
  26. lineWidth: 1
  27. };
  28. };
  29. _proto.createPath = function createPath(context) {
  30. var attrs = this.get('attrs');
  31. var x = attrs.x,
  32. y = attrs.y,
  33. r = attrs.r,
  34. startAngle = attrs.startAngle,
  35. endAngle = attrs.endAngle,
  36. clockwise = attrs.clockwise;
  37. context.beginPath();
  38. context.arc(x, y, r, startAngle, endAngle, clockwise);
  39. };
  40. _proto.calculateBox = function calculateBox() {
  41. var attrs = this.get('attrs');
  42. var x = attrs.x,
  43. y = attrs.y,
  44. r = attrs.r,
  45. startAngle = attrs.startAngle,
  46. endAngle = attrs.endAngle,
  47. clockwise = attrs.clockwise;
  48. return bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
  49. };
  50. return Arc;
  51. }(Shape);
  52. Shape.Arc = Arc;
  53. module.exports = Arc;