CompoundPath.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { __extends } from "tslib";
  2. import Path from './Path.js';
  3. var CompoundPath = (function (_super) {
  4. __extends(CompoundPath, _super);
  5. function CompoundPath() {
  6. var _this = _super !== null && _super.apply(this, arguments) || this;
  7. _this.type = 'compound';
  8. return _this;
  9. }
  10. CompoundPath.prototype._updatePathDirty = function () {
  11. var paths = this.shape.paths;
  12. var dirtyPath = this.shapeChanged();
  13. for (var i = 0; i < paths.length; i++) {
  14. dirtyPath = dirtyPath || paths[i].shapeChanged();
  15. }
  16. if (dirtyPath) {
  17. this.dirtyShape();
  18. }
  19. };
  20. CompoundPath.prototype.beforeBrush = function () {
  21. this._updatePathDirty();
  22. var paths = this.shape.paths || [];
  23. var scale = this.getGlobalScale();
  24. for (var i = 0; i < paths.length; i++) {
  25. if (!paths[i].path) {
  26. paths[i].createPathProxy();
  27. }
  28. paths[i].path.setScale(scale[0], scale[1], paths[i].segmentIgnoreThreshold);
  29. }
  30. };
  31. CompoundPath.prototype.buildPath = function (ctx, shape) {
  32. var paths = shape.paths || [];
  33. for (var i = 0; i < paths.length; i++) {
  34. paths[i].buildPath(ctx, paths[i].shape, true);
  35. }
  36. };
  37. CompoundPath.prototype.afterBrush = function () {
  38. var paths = this.shape.paths || [];
  39. for (var i = 0; i < paths.length; i++) {
  40. paths[i].pathUpdated();
  41. }
  42. };
  43. CompoundPath.prototype.getBoundingRect = function () {
  44. this._updatePathDirty.call(this);
  45. return Path.prototype.getBoundingRect.call(this);
  46. };
  47. return CompoundPath;
  48. }(Path));
  49. export default CompoundPath;