mroot.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.CommonMrootMixin = void 0;
  19. function CommonMrootMixin(Base) {
  20. return (function (_super) {
  21. __extends(class_1, _super);
  22. function class_1() {
  23. return _super !== null && _super.apply(this, arguments) || this;
  24. }
  25. Object.defineProperty(class_1.prototype, "surd", {
  26. get: function () {
  27. return 2;
  28. },
  29. enumerable: false,
  30. configurable: true
  31. });
  32. Object.defineProperty(class_1.prototype, "root", {
  33. get: function () {
  34. return 1;
  35. },
  36. enumerable: false,
  37. configurable: true
  38. });
  39. class_1.prototype.combineRootBBox = function (BBOX, sbox, H) {
  40. var bbox = this.childNodes[this.root].getOuterBBox();
  41. var h = this.getRootDimens(sbox, H)[1];
  42. BBOX.combine(bbox, 0, h);
  43. };
  44. class_1.prototype.getRootDimens = function (sbox, H) {
  45. var surd = this.childNodes[this.surd];
  46. var bbox = this.childNodes[this.root].getOuterBBox();
  47. var offset = (surd.size < 0 ? .5 : .6) * sbox.w;
  48. var w = bbox.w, rscale = bbox.rscale;
  49. var W = Math.max(w, offset / rscale);
  50. var dx = Math.max(0, W - w);
  51. var h = this.rootHeight(bbox, sbox, surd.size, H);
  52. var x = W * rscale - offset;
  53. return [x, h, dx];
  54. };
  55. class_1.prototype.rootHeight = function (rbox, sbox, size, H) {
  56. var h = sbox.h + sbox.d;
  57. var b = (size < 0 ? 1.9 : .55 * h) - (h - H);
  58. return b + Math.max(0, rbox.d * rbox.rscale);
  59. };
  60. return class_1;
  61. }(Base));
  62. }
  63. exports.CommonMrootMixin = CommonMrootMixin;
  64. //# sourceMappingURL=mroot.js.map