Droplet.js 1004 B

12345678910111213141516171819202122232425262728293031323334
  1. import { __extends } from "tslib";
  2. import Path from '../Path.js';
  3. var DropletShape = (function () {
  4. function DropletShape() {
  5. this.cx = 0;
  6. this.cy = 0;
  7. this.width = 0;
  8. this.height = 0;
  9. }
  10. return DropletShape;
  11. }());
  12. export { DropletShape };
  13. var Droplet = (function (_super) {
  14. __extends(Droplet, _super);
  15. function Droplet(opts) {
  16. return _super.call(this, opts) || this;
  17. }
  18. Droplet.prototype.getDefaultShape = function () {
  19. return new DropletShape();
  20. };
  21. Droplet.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 + a);
  27. ctx.bezierCurveTo(x + a, y + a, x + a * 3 / 2, y - a / 3, x, y - b);
  28. ctx.bezierCurveTo(x - a * 3 / 2, y - a / 3, x - a, y + a, x, y + a);
  29. ctx.closePath();
  30. };
  31. return Droplet;
  32. }(Path));
  33. Droplet.prototype.type = 'droplet';
  34. export default Droplet;