Ring.js 884 B

123456789101112131415161718192021222324252627282930313233
  1. import { __extends } from "tslib";
  2. import Path from '../Path.js';
  3. var RingShape = (function () {
  4. function RingShape() {
  5. this.cx = 0;
  6. this.cy = 0;
  7. this.r = 0;
  8. this.r0 = 0;
  9. }
  10. return RingShape;
  11. }());
  12. export { RingShape };
  13. var Ring = (function (_super) {
  14. __extends(Ring, _super);
  15. function Ring(opts) {
  16. return _super.call(this, opts) || this;
  17. }
  18. Ring.prototype.getDefaultShape = function () {
  19. return new RingShape();
  20. };
  21. Ring.prototype.buildPath = function (ctx, shape) {
  22. var x = shape.cx;
  23. var y = shape.cy;
  24. var PI2 = Math.PI * 2;
  25. ctx.moveTo(x + shape.r, y);
  26. ctx.arc(x, y, shape.r, 0, PI2, false);
  27. ctx.moveTo(x + shape.r0, y);
  28. ctx.arc(x, y, shape.r0, 0, PI2, true);
  29. };
  30. return Ring;
  31. }(Path));
  32. Ring.prototype.type = 'ring';
  33. export default Ring;