Arc.js 735 B

1234567891011121314151617181920212223242526272829303132333435
  1. var Path = require("../Path");
  2. /**
  3. * 圆弧
  4. * @module zrender/graphic/shape/Arc
  5. */
  6. var _default = Path.extend({
  7. type: 'arc',
  8. shape: {
  9. cx: 0,
  10. cy: 0,
  11. r: 0,
  12. startAngle: 0,
  13. endAngle: Math.PI * 2,
  14. clockwise: true
  15. },
  16. style: {
  17. stroke: '#000',
  18. fill: null
  19. },
  20. buildPath: function (ctx, shape) {
  21. var x = shape.cx;
  22. var y = shape.cy;
  23. var r = Math.max(shape.r, 0);
  24. var startAngle = shape.startAngle;
  25. var endAngle = shape.endAngle;
  26. var clockwise = shape.clockwise;
  27. var unitX = Math.cos(startAngle);
  28. var unitY = Math.sin(startAngle);
  29. ctx.moveTo(unitX * r + x, unitY * r + y);
  30. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  31. }
  32. });
  33. module.exports = _default;