Heart.js 959 B

123456789101112131415161718192021222324252627282930313233
  1. import { __extends } from "tslib";
  2. import Path from '../Path.js';
  3. var HeartShape = (function () {
  4. function HeartShape() {
  5. this.cx = 0;
  6. this.cy = 0;
  7. this.width = 0;
  8. this.height = 0;
  9. }
  10. return HeartShape;
  11. }());
  12. export { HeartShape };
  13. var Heart = (function (_super) {
  14. __extends(Heart, _super);
  15. function Heart(opts) {
  16. return _super.call(this, opts) || this;
  17. }
  18. Heart.prototype.getDefaultShape = function () {
  19. return new HeartShape();
  20. };
  21. Heart.prototype.buildPath = function (ctx, shape) {
  22. var x = shape.cx;
  23. var y = shape.cy;
  24. var a = shape.width;
  25. var b = shape.height;
  26. ctx.moveTo(x, y);
  27. ctx.bezierCurveTo(x + a / 2, y - b * 2 / 3, x + a * 2, y + b / 3, x, y + b);
  28. ctx.bezierCurveTo(x - a * 2, y + b / 3, x - a / 2, y - b * 2 / 3, x, y);
  29. };
  30. return Heart;
  31. }(Path));
  32. Heart.prototype.type = 'heart';
  33. export default Heart;