figureone 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -11338,6 +11338,12 @@ var FigureElement = /*#__PURE__*/function () {
11338
11338
 
11339
11339
  // TODO
11340
11340
 
11341
+ // `setColor` commands can be tagged with a `from` source label (e.g. an
11342
+ // equation tags its default-color cascade with 'form'). An element listed
11343
+ // against a source in `ignoreSetColor` will ignore commands from that source
11344
+ // while still honoring untagged (explicit) commands like `dim`/`undim` or a
11345
+ // direct `setColor`. Accepts a single source string or a list of them.
11346
+
11341
11347
  // // TODO
11342
11348
  // move: {
11343
11349
  // line: Line,
@@ -11380,6 +11386,7 @@ var FigureElement = /*#__PURE__*/function () {
11380
11386
  this.isFormIgnored = false;
11381
11387
  this.simple = false;
11382
11388
  this.allowSetColor = 'all';
11389
+ this.ignoreSetColor = [];
11383
11390
  this.transform = transform._dup();
11384
11391
  this.dependantTransform = false;
11385
11392
  this.fnMap = new _tools_FunctionMap__WEBPACK_IMPORTED_MODULE_13__.FunctionMap();
@@ -12331,15 +12338,39 @@ var FigureElement = /*#__PURE__*/function () {
12331
12338
  return false;
12332
12339
  }
12333
12340
 
12341
+ /**
12342
+ * Returns `true` if a `setColor` command tagged with source `from` should be
12343
+ * ignored by this element (per `ignoreSetColor`). Untagged commands
12344
+ * (`from == null`) are never ignored.
12345
+ */
12346
+ }, {
12347
+ key: "isSetColorIgnored",
12348
+ value: function isSetColorIgnored() {
12349
+ var from = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
12350
+ if (from == null) {
12351
+ return false;
12352
+ }
12353
+ if (typeof this.ignoreSetColor === 'string') {
12354
+ return this.ignoreSetColor === from;
12355
+ }
12356
+ return this.ignoreSetColor.indexOf(from) > -1;
12357
+ }
12358
+
12334
12359
  /**
12335
12360
  Set element color.
12336
12361
  @param {[number, number, number, number]} color RGBA color from 0 to 1
12337
12362
  @param {boolean} [setDefault] also set the default color to this color
12363
+ @param {string | null} [from] source label of this color command; if it
12364
+ matches `ignoreSetColor` the command is ignored
12338
12365
  */
12339
12366
  }, {
12340
12367
  key: "setColor",
12341
12368
  value: function setColor(color) {
12342
12369
  var setDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12370
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
12371
+ if (this.isSetColorIgnored(from)) {
12372
+ return;
12373
+ }
12343
12374
  if (this.allowSetColor === 'all') {
12344
12375
  this.color = color != null ? color.slice() : [0, 0, 0, 0];
12345
12376
  } else if (this.allowSetColor === 'opacity') {
@@ -14577,6 +14608,10 @@ var FigureElementPrimitive = /*#__PURE__*/function (_FigureElement) {
14577
14608
  key: "setColor",
14578
14609
  value: function setColor(color) {
14579
14610
  var setDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
14611
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
14612
+ if (this.isSetColorIgnored(from)) {
14613
+ return;
14614
+ }
14580
14615
  if (this.allowSetColor === 'all') {
14581
14616
  this.color = color != null ? color.slice() : [0, 0, 0, 0];
14582
14617
  } else if (this.allowSetColor === 'opacity') {
@@ -16307,11 +16342,15 @@ var FigureElementCollection = /*#__PURE__*/function (_FigureElement2) {
16307
16342
  value: function setColor() {
16308
16343
  var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0, 0, 0, 1];
16309
16344
  var setDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
16345
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
16346
+ if (this.isSetColorIgnored(from)) {
16347
+ return;
16348
+ }
16310
16349
  var nonNullColor = color != null ? color : [0, 0, 0, 0];
16311
16350
  for (var i = 0; i < this.drawOrder.length; i += 1) {
16312
16351
  var element = this.elements[this.drawOrder[i]];
16313
16352
  if (!this.preserveChildColor) {
16314
- element.setColor(nonNullColor, setDefault);
16353
+ element.setColor(nonNullColor, setDefault, from);
16315
16354
  }
16316
16355
  }
16317
16356
  if (this.allowSetColor === 'all') {
@@ -17185,8 +17224,14 @@ function offsetLocationForAnnotations(annotations, offset) {
17185
17224
  });
17186
17225
  }
17187
17226
  function setColorForAnnotations(annotations, color) {
17227
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
17188
17228
  annotations.forEach(function (annotation) {
17189
- annotation.content.setColor(color);
17229
+ annotation.content.setColor(color, from);
17230
+ });
17231
+ }
17232
+ function setOpacityForAnnotations(annotations, opacity) {
17233
+ annotations.forEach(function (annotation) {
17234
+ annotation.content.setOpacity(opacity);
17190
17235
  });
17191
17236
  }
17192
17237
  function setPositionsForGlyphs(glyphs) {
@@ -17203,15 +17248,28 @@ function setPositionsForGlyphs(glyphs) {
17203
17248
  });
17204
17249
  }
17205
17250
  function setColorForGlyphs(glyphs, color) {
17251
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
17206
17252
  Object.keys(glyphs).forEach(function (key) {
17207
17253
  if (glyphs[key] == null) {
17208
17254
  return;
17209
17255
  }
17210
17256
  var glyph = glyphs[key];
17211
17257
  if (color != null) {
17212
- glyph.glyph.setColor(color);
17258
+ glyph.glyph.setColor(color, true, from);
17213
17259
  }
17214
- setColorForAnnotations(glyph.annotations, color);
17260
+ setColorForAnnotations(glyph.annotations, color, from);
17261
+ });
17262
+ }
17263
+ function setOpacityForGlyphs(glyphs, opacity) {
17264
+ Object.keys(glyphs).forEach(function (key) {
17265
+ if (glyphs[key] == null) {
17266
+ return;
17267
+ }
17268
+ var glyph = glyphs[key];
17269
+ if (opacity != null) {
17270
+ glyph.glyph.setOpacity(opacity);
17271
+ }
17272
+ setOpacityForAnnotations(glyph.annotations, opacity);
17215
17273
  });
17216
17274
  }
17217
17275
  function offsetLocationForGlyphs(glyphs, offset) {
@@ -17240,6 +17298,7 @@ var BaseAnnotationFunction = /*#__PURE__*/function () {
17240
17298
  this.showContent = showContent;
17241
17299
  this.scale = 1;
17242
17300
  this.color = null;
17301
+ this.opacity = null;
17243
17302
  this.functionName = null;
17244
17303
  }
17245
17304
  return _createClass(BaseAnnotationFunction, [{
@@ -17277,15 +17336,38 @@ var BaseAnnotationFunction = /*#__PURE__*/function () {
17277
17336
  key: "setColor",
17278
17337
  value: function setColor() {
17279
17338
  var colorIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
17339
+ var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
17280
17340
  var color = null;
17341
+ var nextFrom = from;
17281
17342
  if (this.color != null) {
17282
17343
  color = this.color;
17344
+ nextFrom = null;
17283
17345
  } else if (colorIn != null) {
17284
17346
  color = colorIn;
17285
17347
  }
17286
- this.content.setColor(color);
17287
- setColorForAnnotations(this.annotations, color);
17288
- setColorForGlyphs(this.glyphs, color);
17348
+ this.content.setColor(color, nextFrom);
17349
+ setColorForAnnotations(this.annotations, color, nextFrom);
17350
+ setColorForGlyphs(this.glyphs, color, nextFrom);
17351
+ }
17352
+ }, {
17353
+ key: "setOpacity",
17354
+ value: function setOpacity() {
17355
+ var opacityIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
17356
+ var opacity = opacityIn;
17357
+ if (this.opacity != null) {
17358
+ opacity = (opacity == null ? 1 : opacity) * this.opacity;
17359
+ }
17360
+ this.content.setOpacity(opacity);
17361
+ setOpacityForAnnotations(this.annotations, opacity);
17362
+ setOpacityForGlyphs(this.glyphs, opacity);
17363
+ }
17364
+ }, {
17365
+ key: "collectDrawOrder",
17366
+ value: function collectDrawOrder(ops) {
17367
+ this.content.collectDrawOrder(ops);
17368
+ this.annotations.forEach(function (annotation) {
17369
+ annotation.content.collectDrawOrder(ops);
17370
+ });
17289
17371
  }
17290
17372
  }, {
17291
17373
  key: "offsetLocation",
@@ -17985,20 +18067,45 @@ var BaseEquationFunction = /*#__PURE__*/function (_Elements) {
17985
18067
  key: "setColor",
17986
18068
  value: function setColor() {
17987
18069
  var colorIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18070
+ var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
17988
18071
  var color = null;
18072
+ // An explicit `color` function supplies its own `this.color`; re-stamp the
18073
+ // provenance to null so this color is treated as an explicit command and is
18074
+ // not ignored by a child that ignores the 'form' default cascade.
18075
+ var nextFrom = from;
17989
18076
  if (this.color != null) {
17990
18077
  color = this.color;
18078
+ nextFrom = null;
17991
18079
  } else if (colorIn != null) {
17992
18080
  color = colorIn;
17993
18081
  }
17994
18082
  this.glyphs.forEach(function (glyph) {
17995
18083
  if (glyph != null && color != null) {
17996
- glyph.setColor(color);
18084
+ glyph.setColor(color, true, nextFrom);
17997
18085
  }
17998
18086
  });
17999
18087
  this.contents.forEach(function (content) {
18000
18088
  if (content != null) {
18001
- content.setColor(color);
18089
+ content.setColor(color, nextFrom);
18090
+ }
18091
+ });
18092
+ }
18093
+ }, {
18094
+ key: "setOpacity",
18095
+ value: function setOpacity() {
18096
+ var opacityIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18097
+ var opacity = opacityIn;
18098
+ if (this.opacity != null) {
18099
+ opacity = (opacity == null ? 1 : opacity) * this.opacity;
18100
+ }
18101
+ this.glyphs.forEach(function (glyph) {
18102
+ if (glyph != null && opacity != null) {
18103
+ glyph.setOpacity(opacity);
18104
+ }
18105
+ });
18106
+ this.contents.forEach(function (content) {
18107
+ if (content != null) {
18108
+ content.setOpacity(opacity);
18002
18109
  }
18003
18110
  });
18004
18111
  }
@@ -18375,6 +18482,118 @@ var Container = /*#__PURE__*/function (_BaseEquationFunction) {
18375
18482
  }(_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_1__["default"]);
18376
18483
 
18377
18484
 
18485
+ /***/ },
18486
+
18487
+ /***/ "./src/js/figure/Equation/Elements/DrawOrder.ts"
18488
+ /*!******************************************************!*\
18489
+ !*** ./src/js/figure/Equation/Elements/DrawOrder.ts ***!
18490
+ \******************************************************/
18491
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
18492
+
18493
+ __webpack_require__.r(__webpack_exports__);
18494
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
18495
+ /* harmony export */ "default": () => (/* binding */ DrawOrder)
18496
+ /* harmony export */ });
18497
+ /* harmony import */ var _Element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Element */ "./src/js/figure/Element.ts");
18498
+ /* harmony import */ var _Bounds__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Bounds */ "./src/js/figure/Equation/Elements/Bounds.ts");
18499
+ /* harmony import */ var _BaseEquationFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BaseEquationFunction */ "./src/js/figure/Equation/Elements/BaseEquationFunction.ts");
18500
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
18501
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
18502
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18503
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
18504
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18505
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18506
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
18507
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
18508
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
18509
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18510
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18511
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18512
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
18513
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
18514
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
18515
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
18516
+ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
18517
+ function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
18518
+ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
18519
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
18520
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
18521
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
18522
+
18523
+
18524
+
18525
+
18526
+ // Layout-neutral wrapper that records a draw-order operation (`front` or
18527
+ // `back`) for the elements it wraps. The actual reordering of the equation
18528
+ // collection's draw stack is performed by `EquationForm.setPositions` after the
18529
+ // ops are gathered with `collectDrawOrder` (paralleling the `color`/`opacity`
18530
+ // cascade). `front` true moves wrapped elements forward in the draw stack,
18531
+ // `front` false moves them back. `num` is the number of places to move; when
18532
+ // `null` the elements are moved completely to the front/back.
18533
+ var DrawOrder = /*#__PURE__*/function (_BaseEquationFunction) {
18534
+ function DrawOrder() {
18535
+ _classCallCheck(this, DrawOrder);
18536
+ return _callSuper(this, DrawOrder, arguments);
18537
+ }
18538
+ _inherits(DrawOrder, _BaseEquationFunction);
18539
+ return _createClass(DrawOrder, [{
18540
+ key: "calcSize",
18541
+ value: function calcSize(location, scale) {
18542
+ this.location = location._dup();
18543
+ var loc = location._dup();
18544
+ var fullContentBounds = this.options.fullContentBounds;
18545
+ var _this$contents = _slicedToArray(this.contents, 1),
18546
+ mainContent = _this$contents[0];
18547
+ var contentBounds = new _Bounds__WEBPACK_IMPORTED_MODULE_1__["default"]();
18548
+ var fullBounds = new _Bounds__WEBPACK_IMPORTED_MODULE_1__["default"]();
18549
+ if (mainContent != null) {
18550
+ mainContent.calcSize(loc._dup(), scale);
18551
+ contentBounds.copyFrom(mainContent.getBounds(fullContentBounds));
18552
+ fullBounds.copyFrom(mainContent.getBounds(true));
18553
+ }
18554
+ this.width = contentBounds.width;
18555
+ this.height = contentBounds.height;
18556
+ this.descent = contentBounds.descent;
18557
+ this.ascent = contentBounds.ascent;
18558
+ this.fullSize = {
18559
+ leftOffset: this.location.x - fullBounds.left,
18560
+ width: fullBounds.width,
18561
+ ascent: fullBounds.ascent,
18562
+ descent: fullBounds.descent,
18563
+ height: fullBounds.height
18564
+ };
18565
+ }
18566
+ }, {
18567
+ key: "collectDrawOrder",
18568
+ value: function collectDrawOrder(ops) {
18569
+ // Collect nested front/back ops first so they are applied before this one.
18570
+ // Each op moves its element group while preserving the group's *current*
18571
+ // relative draw order, so a nested front/back reorders the elements and the
18572
+ // outer (this) op then moves the reordered group as a unit. This composes
18573
+ // consistently: the innermost op runs first, the outermost last.
18574
+ _superPropGet(DrawOrder, "collectDrawOrder", this, 3)([ops]);
18575
+ var _this$options = this.options,
18576
+ front = _this$options.front,
18577
+ num = _this$options.num,
18578
+ before = _this$options.before,
18579
+ after = _this$options.after;
18580
+ var elements = this.getAllElements(true).filter(function (e) {
18581
+ return e instanceof _Element__WEBPACK_IMPORTED_MODULE_0__.FigureElementPrimitive || e instanceof _Element__WEBPACK_IMPORTED_MODULE_0__.FigureElementCollection;
18582
+ });
18583
+ if (elements.length > 0) {
18584
+ ops.push({
18585
+ front: front,
18586
+ num: num,
18587
+ before: before,
18588
+ after: after,
18589
+ elements: elements
18590
+ });
18591
+ }
18592
+ }
18593
+ }]);
18594
+ }(_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_2__["default"]);
18595
+
18596
+
18378
18597
  /***/ },
18379
18598
 
18380
18599
  /***/ "./src/js/figure/Equation/Elements/Element.ts"
@@ -18452,6 +18671,7 @@ var Element = /*#__PURE__*/function () {
18452
18671
  };
18453
18672
  this.color = null;
18454
18673
  this.defaultColor = content.color.slice();
18674
+ this.opacity = null;
18455
18675
  this.fnMap = new _tools_FunctionMap__WEBPACK_IMPORTED_MODULE_4__.FunctionMap();
18456
18676
  this.showContent = true;
18457
18677
  }
@@ -18567,20 +18787,52 @@ var Element = /*#__PURE__*/function () {
18567
18787
  key: "setColor",
18568
18788
  value: function setColor() {
18569
18789
  var colorIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18790
+ var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
18570
18791
  var color = this.defaultColor;
18792
+ // `from` carries the provenance of the cascade down to the FigureElement.
18793
+ // If this wrapper supplies its own explicit color, re-stamp `from` to null
18794
+ // (an explicit command) so a child cannot ignore it as a 'form' default.
18795
+ var nextFrom = from;
18571
18796
  if (colorIn != null) {
18572
18797
  color = colorIn;
18573
18798
  } else if (this.color != null) {
18574
18799
  color = this.color;
18800
+ nextFrom = null;
18575
18801
  }
18576
18802
  var content = this.content;
18577
18803
  if (content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementCollection || content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementPrimitive) {
18578
18804
  if (content.isFormIgnored) {
18579
18805
  return;
18580
18806
  }
18581
- content.setColor(color);
18807
+ content.setColor(color, true, nextFrom);
18582
18808
  }
18583
18809
  }
18810
+ }, {
18811
+ key: "setOpacity",
18812
+ value: function setOpacity() {
18813
+ var opacityIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18814
+ var opacity = opacityIn;
18815
+ if (this.opacity != null) {
18816
+ opacity = (opacity == null ? 1 : opacity) * this.opacity;
18817
+ }
18818
+ if (opacity == null) {
18819
+ return;
18820
+ }
18821
+ var content = this.content;
18822
+ if (content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementCollection || content instanceof _Element__WEBPACK_IMPORTED_MODULE_3__.FigureElementPrimitive) {
18823
+ if (content.isFormIgnored) {
18824
+ return;
18825
+ }
18826
+ content.setOpacity(opacity);
18827
+ }
18828
+ }
18829
+
18830
+ // eslint-disable-next-line class-methods-use-this, no-unused-vars
18831
+ }, {
18832
+ key: "collectDrawOrder",
18833
+ value: function collectDrawOrder(ops) {
18834
+ // A leaf element holds no draw-order operation.
18835
+ }
18584
18836
  }, {
18585
18837
  key: "offsetLocation",
18586
18838
  value: function offsetLocation() {
@@ -18634,6 +18886,7 @@ var Elements = /*#__PURE__*/function () {
18634
18886
  this.fnMap = new _tools_FunctionMap__WEBPACK_IMPORTED_MODULE_4__.FunctionMap();
18635
18887
  this.showContent = true;
18636
18888
  this.color = null;
18889
+ this.opacity = null;
18637
18890
  }
18638
18891
  return _createClass(Elements, [{
18639
18892
  key: "cleanup",
@@ -18719,14 +18972,36 @@ var Elements = /*#__PURE__*/function () {
18719
18972
  key: "setColor",
18720
18973
  value: function setColor() {
18721
18974
  var colorIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18975
+ var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
18722
18976
  var color = null;
18977
+ var nextFrom = from;
18723
18978
  if (this.color != null) {
18724
18979
  color = this.color;
18980
+ nextFrom = null;
18725
18981
  } else if (colorIn != null) {
18726
18982
  color = colorIn;
18727
18983
  }
18728
18984
  this.content.forEach(function (e) {
18729
- e.setColor(color);
18985
+ e.setColor(color, nextFrom);
18986
+ });
18987
+ }
18988
+ }, {
18989
+ key: "setOpacity",
18990
+ value: function setOpacity() {
18991
+ var opacityIn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
18992
+ var opacity = opacityIn;
18993
+ if (this.opacity != null) {
18994
+ opacity = (opacity == null ? 1 : opacity) * this.opacity;
18995
+ }
18996
+ this.content.forEach(function (e) {
18997
+ e.setOpacity(opacity);
18998
+ });
18999
+ }
19000
+ }, {
19001
+ key: "collectDrawOrder",
19002
+ value: function collectDrawOrder(ops) {
19003
+ this.content.forEach(function (e) {
19004
+ e.collectDrawOrder(ops);
18730
19005
  });
18731
19006
  }
18732
19007
  }, {
@@ -19359,6 +19634,81 @@ var Offset = /*#__PURE__*/function (_BaseEquationFunction) {
19359
19634
  }(_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_1__["default"]);
19360
19635
 
19361
19636
 
19637
+ /***/ },
19638
+
19639
+ /***/ "./src/js/figure/Equation/Elements/Opacity.ts"
19640
+ /*!****************************************************!*\
19641
+ !*** ./src/js/figure/Equation/Elements/Opacity.ts ***!
19642
+ \****************************************************/
19643
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
19644
+
19645
+ __webpack_require__.r(__webpack_exports__);
19646
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
19647
+ /* harmony export */ "default": () => (/* binding */ Opacity)
19648
+ /* harmony export */ });
19649
+ /* harmony import */ var _Bounds__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Bounds */ "./src/js/figure/Equation/Elements/Bounds.ts");
19650
+ /* harmony import */ var _BaseEquationFunction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BaseEquationFunction */ "./src/js/figure/Equation/Elements/BaseEquationFunction.ts");
19651
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
19652
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
19653
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19654
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
19655
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
19656
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19657
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
19658
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19659
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
19660
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
19661
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19662
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19663
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
19664
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
19665
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
19666
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19667
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
19668
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
19669
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
19670
+
19671
+
19672
+ var Opacity = /*#__PURE__*/function (_BaseEquationFunction) {
19673
+ function Opacity() {
19674
+ _classCallCheck(this, Opacity);
19675
+ return _callSuper(this, Opacity, arguments);
19676
+ }
19677
+ _inherits(Opacity, _BaseEquationFunction);
19678
+ return _createClass(Opacity, [{
19679
+ key: "calcSize",
19680
+ value: function calcSize(location, scale) {
19681
+ this.location = location._dup();
19682
+ var loc = location._dup();
19683
+ var _this$options = this.options,
19684
+ opacity = _this$options.opacity,
19685
+ fullContentBounds = _this$options.fullContentBounds;
19686
+ var _this$contents = _slicedToArray(this.contents, 1),
19687
+ mainContent = _this$contents[0];
19688
+ var contentBounds = new _Bounds__WEBPACK_IMPORTED_MODULE_0__["default"]();
19689
+ var fullBounds = new _Bounds__WEBPACK_IMPORTED_MODULE_0__["default"]();
19690
+ if (mainContent != null) {
19691
+ mainContent.calcSize(loc._dup(), scale);
19692
+ contentBounds.copyFrom(mainContent.getBounds(fullContentBounds));
19693
+ fullBounds.copyFrom(mainContent.getBounds(true));
19694
+ }
19695
+ this.opacity = opacity;
19696
+ this.width = contentBounds.width;
19697
+ this.height = contentBounds.height;
19698
+ this.descent = contentBounds.descent;
19699
+ this.ascent = contentBounds.ascent;
19700
+ this.fullSize = {
19701
+ leftOffset: this.location.x - fullBounds.left,
19702
+ width: fullBounds.width,
19703
+ ascent: fullBounds.ascent,
19704
+ descent: fullBounds.descent,
19705
+ height: fullBounds.height
19706
+ };
19707
+ }
19708
+ }]);
19709
+ }(_BaseEquationFunction__WEBPACK_IMPORTED_MODULE_1__["default"]);
19710
+
19711
+
19362
19712
  /***/ },
19363
19713
 
19364
19714
  /***/ "./src/js/figure/Equation/Elements/Scale.ts"
@@ -19518,6 +19868,16 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
19518
19868
  * Object where keys are property names of a {@link FigureElement} and values
19519
19869
  * are the values to set the properties to.
19520
19870
  *
19871
+ * Two keys are treated specially as draw-order operations rather than element
19872
+ * properties: `back` and `front`. Each takes an options object (`{}` for the
19873
+ * full extreme, `{ num }` to move a set number of places, or `{ before }` /
19874
+ * `{ after }` to position relative to an anchor element) and reorders the
19875
+ * element in the equation's draw stack - paralleling the {@link EQN_Back} and
19876
+ * {@link EQN_Front} equation functions. When several elements declare `back` or
19877
+ * `front` mods, they are applied in definition order, so
19878
+ * `{ a: { back: {} }, b: { back: {} } }` sends `a` to the back and then `b` to
19879
+ * the back.
19880
+ *
19521
19881
  * @property {any} [_propertyName]
19522
19882
  * @interface
19523
19883
  * @group Misc Figure Element
@@ -19882,6 +20242,11 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
19882
20242
  * automatically in the equation based on EQN_Color equation functions. In such
19883
20243
  * cases, colors that are set external to the equation will be overridden. Use
19884
20244
  * `true` to allow setting of colors externally only. (`false`)
20245
+ * @property {boolean} [ignoreOpacity] when `false`, opacity will be set
20246
+ * automatically in the equation based on EQN_Opacity equation functions
20247
+ * (multiplicative cascade). Element opacities set externally will be
20248
+ * overridden. Use `true` to allow setting of opacities externally only.
20249
+ * (`false`)
19885
20250
  *
19886
20251
  * @example
19887
20252
  * // Simple form definition of two different forms of the same equation and one
@@ -20377,7 +20742,8 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20377
20742
  },
20378
20743
  elementMods: {},
20379
20744
  layout: 'always',
20380
- ignoreColor: false
20745
+ ignoreColor: false,
20746
+ ignoreOpacity: false
20381
20747
  // lazyLayout: true,
20382
20748
  // layoutonce: false,
20383
20749
  },
@@ -20437,7 +20803,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20437
20803
  // this.setTransform(getTransform(optionsToUse.transform));
20438
20804
  // }
20439
20805
  _this.shapes = shapes;
20440
- _this.setColor(optionsToUse.color);
20806
+ _this.setColor(optionsToUse.color, true, 'form');
20441
20807
  _this.dimColor = optionsToUse.dimColor;
20442
20808
  // this.defaultTextType = optionsToUse.type;
20443
20809
  _this.textureAtlases = {};
@@ -20466,7 +20832,8 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20466
20832
  duration: optionsToUse.formDefaults.duration,
20467
20833
  translation: optionsToUse.formDefaults.translation,
20468
20834
  layout: optionsToUse.formDefaults.layout,
20469
- ignoreColor: optionsToUse.formDefaults.ignoreColor
20835
+ ignoreColor: optionsToUse.formDefaults.ignoreColor,
20836
+ ignoreOpacity: optionsToUse.formDefaults.ignoreOpacity
20470
20837
  },
20471
20838
  functions: new _EquationFunctions__WEBPACK_IMPORTED_MODULE_10__.EquationFunctions(_this.elements, _this.addElementFromKey.bind(_this), _this.getExistingOrAddSymbol.bind(_this), _this.makeInlineElement.bind(_this)),
20472
20839
  symbols: new _EquationSymbols__WEBPACK_IMPORTED_MODULE_9__["default"](_this.shapes, _this.color),
@@ -20930,7 +21297,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20930
21297
  var symbol = this.eqn.symbols.get(cleanKey, options);
20931
21298
  if (symbol != null) {
20932
21299
  if (symbol.color[3] > 0.01 && options.color == null) {
20933
- symbol.setColor(this.color);
21300
+ symbol.setColor(this.color, true, 'form');
20934
21301
  }
20935
21302
  if (options.mods != null) {
20936
21303
  symbol.setProperties(options.mods);
@@ -20957,7 +21324,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
20957
21324
  }
20958
21325
  if (symbol != null) {
20959
21326
  if (symbol.color[3] > 0.01 && options.color == null) {
20960
- symbol.setColor(this.color);
21327
+ symbol.setColor(this.color, true, 'form');
20961
21328
  }
20962
21329
  if (options.mods != null) {
20963
21330
  symbol.setProperties(options.mods);
@@ -21039,7 +21406,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21039
21406
  });
21040
21407
  }
21041
21408
  if (options.color == null && symbol.color[3] > 0.01) {
21042
- symbol.setColor(this.color);
21409
+ symbol.setColor(this.color, true, 'form');
21043
21410
  }
21044
21411
  symbol.dimColor = this.dimColor.slice();
21045
21412
  if (options.mods != null) {
@@ -21222,7 +21589,9 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21222
21589
  translation = _ref.translation,
21223
21590
  fromForm = _ref.fromForm,
21224
21591
  onShow = _ref.onShow,
21225
- onTransition = _ref.onTransition;
21592
+ onTransition = _ref.onTransition,
21593
+ ignoreColor = _ref.ignoreColor,
21594
+ ignoreOpacity = _ref.ignoreOpacity;
21226
21595
  var options = {
21227
21596
  elementMods: elementMods,
21228
21597
  alignment: alignment,
@@ -21233,7 +21602,9 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21233
21602
  duration: duration,
21234
21603
  translation: translation,
21235
21604
  onShow: onShow,
21236
- onTransition: onTransition
21605
+ onTransition: onTransition,
21606
+ ignoreColor: ignoreColor,
21607
+ ignoreOpacity: ignoreOpacity
21237
21608
  };
21238
21609
  try {
21239
21610
  _this7.addForm(name, formContent, options);
@@ -21507,7 +21878,8 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21507
21878
  onTransition = _optionsToUse.onTransition,
21508
21879
  duration = _optionsToUse.duration,
21509
21880
  translation = _optionsToUse.translation,
21510
- ignoreColor = _optionsToUse.ignoreColor;
21881
+ ignoreColor = _optionsToUse.ignoreColor,
21882
+ ignoreOpacity = _optionsToUse.ignoreOpacity;
21511
21883
  var form = this.createForm();
21512
21884
  this.eqn.forms[name] = form;
21513
21885
  form.description = description;
@@ -21519,6 +21891,7 @@ var Equation = /*#__PURE__*/function (_FigureElementCollect) {
21519
21891
  form.onShow = onShow;
21520
21892
  form.onTransition = onTransition;
21521
21893
  form.ignoreColor = ignoreColor;
21894
+ form.ignoreOpacity = ignoreOpacity;
21522
21895
 
21523
21896
  // Populate element mods
21524
21897
  form.elementMods = {};
@@ -22213,6 +22586,12 @@ __webpack_require__.r(__webpack_exports__);
22213
22586
  /* harmony import */ var _Element__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Element */ "./src/js/figure/Element.ts");
22214
22587
  /* harmony import */ var _Elements_Element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Elements/Element */ "./src/js/figure/Equation/Elements/Element.ts");
22215
22588
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
22589
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
22590
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22591
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
22592
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
22593
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
22594
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
22216
22595
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
22217
22596
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
22218
22597
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -22284,6 +22663,7 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22284
22663
  _this.positionsSet = false;
22285
22664
  _this.layout = 'always';
22286
22665
  _this.ignoreColor = false;
22666
+ _this.ignoreOpacity = false;
22287
22667
  // this.subForm = '';
22288
22668
  return _this;
22289
22669
  }
@@ -22317,8 +22697,187 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22317
22697
  }
22318
22698
  _superPropGet(EquationForm, "setPositions", this, 3)([]);
22319
22699
  if (!this.ignoreColor) {
22320
- _superPropGet(EquationForm, "setColor", this, 3)([]);
22700
+ _superPropGet(EquationForm, "setColor", this, 3)([null, 'form']);
22701
+ }
22702
+ if (!this.ignoreOpacity) {
22703
+ _superPropGet(EquationForm, "setOpacity", this, 3)([]);
22321
22704
  }
22705
+ this.setDrawOrder();
22706
+ }
22707
+
22708
+ // Collect the `front`/`back` draw-order operations declared on this form's
22709
+ // `elementMods` (e.g. `elementMods: { a: { back: {} } }`). These are applied
22710
+ // alongside the inline `front`/`back` equation functions, in element-mod key
22711
+ // order, so `{ a: { back: {} }, b: { back: {} } }` sends `a` to the back and
22712
+ // then `b` to the back.
22713
+ }, {
22714
+ key: "collectElementModDrawOrder",
22715
+ value: function collectElementModDrawOrder(ops) {
22716
+ var _this2 = this;
22717
+ Object.keys(this.elementMods).forEach(function (name) {
22718
+ var entry = _this2.elementMods[name];
22719
+ if (entry == null || entry.element == null || entry.mods == null) {
22720
+ return;
22721
+ }
22722
+ var element = entry.element,
22723
+ mods = entry.mods;
22724
+ if (element.isFormIgnored) {
22725
+ return;
22726
+ }
22727
+ var add = function add(modOption, front) {
22728
+ if (modOption === undefined) {
22729
+ return;
22730
+ }
22731
+ var o = modOption == null ? {} : modOption;
22732
+ ops.push({
22733
+ front: front,
22734
+ num: o.num,
22735
+ before: o.before,
22736
+ after: o.after,
22737
+ elements: [element]
22738
+ });
22739
+ };
22740
+ add(mods.back, false);
22741
+ add(mods.front, true);
22742
+ });
22743
+ }
22744
+
22745
+ // Apply any `front`/`back` draw-order operations - both the inline equation
22746
+ // functions (gathered from the form tree) and those declared on `elementMods`.
22747
+ // Operations are applied relative to a baseline (the natural draw order,
22748
+ // captured before the first reorder) so the result is deterministic no matter
22749
+ // how many times `setPositions` runs. The reorder is performed on the shared
22750
+ // equation collection (the common parent of all wrapped elements).
22751
+ }, {
22752
+ key: "setDrawOrder",
22753
+ value: function setDrawOrder() {
22754
+ var _this3 = this;
22755
+ var ops = [];
22756
+ _superPropGet(EquationForm, "collectDrawOrder", this, 3)([ops]);
22757
+ this.collectElementModDrawOrder(ops);
22758
+ // Find the equation collection (the common parent of all child elements).
22759
+ var children = this.collectionMethods.getAllElements();
22760
+ var collection = children != null && children.length > 0 ? children[0].parent : null;
22761
+ if (collection == null) {
22762
+ return;
22763
+ }
22764
+ // Draw order is color-like: once the equation has used front/back at least
22765
+ // once (so a baseline has been captured), every form resets to the natural
22766
+ // baseline before applying its ops - so a form with no front/back restores
22767
+ // the natural draw order. Equations that never use front/back are left
22768
+ // untouched (no baseline, no reset).
22769
+ if (ops.length === 0 && collection.equationDrawOrderBaseline == null) {
22770
+ return;
22771
+ }
22772
+ // Lazily capture / extend the baseline draw order on the shared collection
22773
+ // (so every form resets to the same natural order). New element names (added
22774
+ // after the baseline was captured) are appended in their current order.
22775
+ if (collection.equationDrawOrderBaseline == null) {
22776
+ collection.equationDrawOrderBaseline = [];
22777
+ }
22778
+ var baseline = collection.equationDrawOrderBaseline;
22779
+ var baselineSet = new Set(baseline);
22780
+ collection.drawOrder.forEach(function (name) {
22781
+ if (!baselineSet.has(name)) {
22782
+ baseline.push(name);
22783
+ baselineSet.add(name);
22784
+ }
22785
+ });
22786
+ // Reset to baseline (dropping any names no longer present) before applying.
22787
+ var currentSet = new Set(collection.drawOrder);
22788
+ collection.drawOrder = baseline.filter(function (name) {
22789
+ return currentSet.has(name);
22790
+ });
22791
+ ops.forEach(function (op) {
22792
+ _this3.applyDrawOrderOp(collection, op);
22793
+ });
22794
+ }
22795
+
22796
+ // Move a single op's element group within the equation collection's draw
22797
+ // stack. The group is always kept contiguous and in its current relative
22798
+ // order (front/back does not reorder within the group). The target position
22799
+ // is determined by `before`/`after` (anchor relative) or `num` (relative for
22800
+ // positive, absolute-from-the-extreme for negative), else the full extreme.
22801
+ // eslint-disable-next-line class-methods-use-this
22802
+ }, {
22803
+ key: "applyDrawOrderOp",
22804
+ value: function applyDrawOrderOp(collection, op) {
22805
+ var order = collection.drawOrder;
22806
+ var inGroup = {};
22807
+ op.elements.forEach(function (e) {
22808
+ inGroup[e.name] = true;
22809
+ });
22810
+ // Group names in their current relative draw order, so the move preserves it
22811
+ var group = order.filter(function (name) {
22812
+ return inGroup[name];
22813
+ });
22814
+ if (group.length === 0) {
22815
+ return;
22816
+ }
22817
+ var groupSize = group.length;
22818
+ var minIdx = order.indexOf(group[0]);
22819
+ var maxIdx = order.indexOf(group[groupSize - 1]);
22820
+ var rest = order.filter(function (name) {
22821
+ return !inGroup[name];
22822
+ });
22823
+ var restLength = rest.length;
22824
+ var anchorNames = function anchorNames(anchor) {
22825
+ if (anchor == null) {
22826
+ return [];
22827
+ }
22828
+ var arr = Array.isArray(anchor) ? anchor : [anchor];
22829
+ return arr.map(function (a) {
22830
+ return a != null && a.name != null ? a.name : a;
22831
+ }).filter(function (n) {
22832
+ return typeof n === 'string';
22833
+ });
22834
+ };
22835
+ var target;
22836
+ if (op.before != null) {
22837
+ // Position the group just before the most-back anchor (`num` shifts it
22838
+ // further back; defaults to 0 when an anchor is given). If none of the
22839
+ // named anchors resolve (typo, or the anchor is itself inside the moved
22840
+ // group), leave the group where the baseline placed it rather than
22841
+ // silently sending it to an extreme.
22842
+ var idxs = anchorNames(op.before).map(function (n) {
22843
+ return rest.indexOf(n);
22844
+ }).filter(function (i) {
22845
+ return i > -1;
22846
+ });
22847
+ if (idxs.length === 0) {
22848
+ return;
22849
+ }
22850
+ var num = op.num == null ? 0 : op.num;
22851
+ target = Math.min.apply(Math, _toConsumableArray(idxs)) - num;
22852
+ } else if (op.after != null) {
22853
+ // Position the group just after the most-front anchor (`num` shifts it
22854
+ // further forward; defaults to 0 when an anchor is given). As with
22855
+ // `before`, an unresolved anchor is a no-op.
22856
+ var _idxs = anchorNames(op.after).map(function (n) {
22857
+ return rest.indexOf(n);
22858
+ }).filter(function (i) {
22859
+ return i > -1;
22860
+ });
22861
+ if (_idxs.length === 0) {
22862
+ return;
22863
+ }
22864
+ var _num = op.num == null ? 0 : op.num;
22865
+ target = Math.max.apply(Math, _toConsumableArray(_idxs)) + 1 + _num;
22866
+ } else if (op.num == null) {
22867
+ target = op.front ? restLength : 0;
22868
+ } else {
22869
+ // Positive `num` moves the group that many places relative to its current
22870
+ // edge; negative `num` positions it absolutely, `|num|` places before the
22871
+ // full extreme.
22872
+ var n = op.num;
22873
+ if (op.front) {
22874
+ target = n >= 0 ? maxIdx + n - groupSize + 1 : restLength + n;
22875
+ } else {
22876
+ target = n >= 0 ? minIdx - n : -n;
22877
+ }
22878
+ }
22879
+ target = Math.max(0, Math.min(restLength, target));
22880
+ collection.drawOrder = [].concat(_toConsumableArray(rest.slice(0, target)), _toConsumableArray(group), _toConsumableArray(rest.slice(target)));
22322
22881
  }
22323
22882
  }, {
22324
22883
  key: "_dup",
@@ -22512,7 +23071,7 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22512
23071
  }, {
22513
23072
  key: "dissolveElements",
22514
23073
  value: function dissolveElements(elements) {
22515
- var _this2 = this;
23074
+ var _this4 = this;
22516
23075
  var dissolve = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'in';
22517
23076
  var delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.01;
22518
23077
  var time = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
@@ -22531,7 +23090,7 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22531
23090
  if (completed === count) {
22532
23091
  if (callback) {
22533
23092
  // callback(cancelled);
22534
- _this2.fnMap.exec(callback, cancelled);
23093
+ _this4.fnMap.exec(callback, cancelled);
22535
23094
  }
22536
23095
  }
22537
23096
  };
@@ -22636,7 +23195,7 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22636
23195
  }, {
22637
23196
  key: "allHideShow",
22638
23197
  value: function allHideShow() {
22639
- var _this3 = this;
23198
+ var _this5 = this;
22640
23199
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
22641
23200
  var hideTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
22642
23201
  var blankTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
@@ -22664,11 +23223,11 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22664
23223
  return 0;
22665
23224
  }
22666
23225
  var dissolveOutCallback = function dissolveOutCallback() {
22667
- _this3.setPositions();
23226
+ _this5.setPositions();
22668
23227
  };
22669
23228
  if (elementsToShow.length === 0) {
22670
23229
  dissolveOutCallback = function dissolveOutCallback(cancelled) {
22671
- _this3.setPositions();
23230
+ _this5.setPositions();
22672
23231
  if (callback != null) {
22673
23232
  callback(cancelled);
22674
23233
  }
@@ -22726,7 +23285,9 @@ var EquationForm = /*#__PURE__*/function (_Elements) {
22726
23285
  return;
22727
23286
  }
22728
23287
  if (element != null && mods != null) {
22729
- element.setProperties(mods);
23288
+ // `back`/`front` are draw-order operations handled by setDrawOrder, not
23289
+ // element properties, so don't copy them onto the element.
23290
+ element.setProperties(mods, ['back', 'front']);
22730
23291
  if (mods.color != null) {
22731
23292
  element.setColor(mods.color);
22732
23293
  }
@@ -22966,6 +23527,8 @@ __webpack_require__.r(__webpack_exports__);
22966
23527
  /* harmony import */ var _Symbols_Line__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Symbols/Line */ "./src/js/figure/Equation/Symbols/Line.ts");
22967
23528
  /* harmony import */ var _Elements_Offset__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Elements/Offset */ "./src/js/figure/Equation/Elements/Offset.ts");
22968
23529
  /* harmony import */ var _Elements_Color__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Elements/Color */ "./src/js/figure/Equation/Elements/Color.ts");
23530
+ /* harmony import */ var _Elements_Opacity__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Elements/Opacity */ "./src/js/figure/Equation/Elements/Opacity.ts");
23531
+ /* harmony import */ var _Elements_DrawOrder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Elements/DrawOrder */ "./src/js/figure/Equation/Elements/DrawOrder.ts");
22969
23532
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
22970
23533
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
22971
23534
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -22996,6 +23559,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
22996
23559
 
22997
23560
 
22998
23561
 
23562
+
23563
+
22999
23564
  // import type {
23000
23565
  // EQN_Annotation, EQN_EncompassGlyph, EQN_LeftRightGlyph, EQN_TopBottomGlyph,
23001
23566
  // } from './Elements/BaseAnnotationFunction';
@@ -23048,6 +23613,10 @@ function getFigureElement(elementsObject, name) {
23048
23613
  * - `{ prodOf: `{@link EQN_ProdOf} `}`
23049
23614
  * - `{ topStrike: `{@link EQN_StrikeComment} `}`
23050
23615
  * - `{ bottomStrike: `{@link EQN_StrikeComment} `}`
23616
+ * - `{ color: `{@link EQN_Color} `}`
23617
+ * - `{ opacity: `{@link EQN_Opacity} `}`
23618
+ * - `{ back: `{@link EQN_Back} `}`
23619
+ * - `{ front: `{@link EQN_Front} `}`
23051
23620
  * - `{ make: string, name?: string, ... }` (inline element — creates any
23052
23621
  * element type directly in a form using the same `make` values as
23053
23622
  * {@link Figure.add}. If `name` is omitted, one is auto-generated.)
@@ -23442,6 +24011,243 @@ function getFigureElement(elementsObject, name) {
23442
24011
  * },
23443
24012
  * touch: { onClick: e => e.nextForm() },
23444
24013
  * });
24014
+ * @example
24015
+ * // The `color` function recolours a phrase explicitly. Separately, an element
24016
+ * // can opt out of the equation's default ('form') colour cascade with
24017
+ * // `ignoreSetColor`, while still accepting explicit colour commands. Here both
24018
+ * // squares start blue; recolouring the whole equation to grey greys the left
24019
+ * // (free) square, but the right (locked) square keeps its colour.
24020
+ * const blue = [0, 0, 1, 1];
24021
+ * const locked = figure.primitives.rectangle({ width: 0.5, height: 0.5, color: blue });
24022
+ * locked.ignoreSetColor = 'form'; // ignore the default cascade, keep blue
24023
+ * const eqn = figure.add({
24024
+ * make: 'equation',
24025
+ * color: [1, 0, 0, 1],
24026
+ * elements: {
24027
+ * free: figure.primitives.rectangle({ width: 0.5, height: 0.5, color: blue }),
24028
+ * locked,
24029
+ * },
24030
+ * forms: { 0: ['free', ' ', 'locked'] },
24031
+ * });
24032
+ * eqn.setColor([0.5, 0.5, 0.5, 1], true, 'form'); // free -> grey, locked stays blue
24033
+ * @interface
24034
+ * @group Equation Layout
24035
+ */
24036
+
24037
+ /**
24038
+ * Equation opacity function
24039
+ *
24040
+ * Set an opacity multiplier on an equation phrase. The opacity cascades
24041
+ * multiplicatively, so nested `opacity` functions multiply together (e.g. an
24042
+ * outer `0.5` around an inner `0.5` yields `0.25` on the inner content).
24043
+ *
24044
+ * Opacity values are expected to be in the range `[0, 1]`. Whenever the form
24045
+ * is shown, the cascaded opacity is assigned to each wrapped element, overriding
24046
+ * any externally-set element `opacity`. Set `ignoreOpacity: true` on the form
24047
+ * to suppress this and preserve externally-set opacities.
24048
+ *
24049
+ * Options can be an object, or an array in the property order below
24050
+ *
24051
+ * @property {TypeEquationPhrase} content
24052
+ * @property {number} opacity opacity multiplier in the range `[0, 1]`
24053
+ * @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
24054
+ *
24055
+ * @see To test examples, append them to the
24056
+ * <a href="#drawing-boilerplate">boilerplate</a>
24057
+ *
24058
+ * @example
24059
+ * // Simple Array Definition
24060
+ * figure.add({
24061
+ * make: 'equation',
24062
+ * forms: {
24063
+ * 0: ['a', { opacity: ['b', 0.3] }, 'c'],
24064
+ * },
24065
+ * });
24066
+ *
24067
+ * @example
24068
+ * // Simple Object Definition
24069
+ * figure.add({
24070
+ * make: 'equation',
24071
+ * forms: {
24072
+ * 0: [
24073
+ * 'a',
24074
+ * {
24075
+ * opacity: {
24076
+ * content: 'b',
24077
+ * opacity: 0.3,
24078
+ * },
24079
+ * },
24080
+ * 'c',
24081
+ * ],
24082
+ * },
24083
+ * });
24084
+ *
24085
+ * @interface
24086
+ * @group Equation Layout
24087
+ */
24088
+
24089
+ /**
24090
+ * Equation back function
24091
+ *
24092
+ * Send an equation phrase's elements back in the equation's draw stack. All
24093
+ * elements within `content` are moved together as a group, keeping their
24094
+ * current relative draw order. Nested `front`/`back` functions are applied
24095
+ * inner-most first, so an inner `front`/`back` reorders the elements and this
24096
+ * (outer) function then moves the reordered group as a unit.
24097
+ *
24098
+ * The group's position is determined by, in order of precedence:
24099
+ * - `before` - position the group just before (behind) the most-back of the
24100
+ * named anchor element(s). `num` shifts it further back (default `0`).
24101
+ * - `after` - position the group just after (in front of) the most-front of
24102
+ * the named anchor element(s). `num` shifts it further forward (default `0`).
24103
+ * - `num` - a positive value moves the group that many places back; a negative
24104
+ * value positions it `|num|` places ahead of the very back.
24105
+ * - otherwise the group is sent completely to the back.
24106
+ *
24107
+ * The reorder is applied whenever the form is shown, relative to the equation's
24108
+ * natural (definition) draw order, so each form deterministically defines its
24109
+ * own stacking.
24110
+ *
24111
+ * Options can be an object, or an array in the property order below
24112
+ *
24113
+ * @property {TypeEquationPhrase} content
24114
+ * @property {number} [num] places to send the group back (positive), or an
24115
+ * absolute position `|num|` places ahead of the full back (negative). When
24116
+ * `before`/`after` is set, `num` is the offset from the anchor (default `0`).
24117
+ * If undefined (and no anchor), the group is sent completely to the back
24118
+ * @property {string | Array<string>} [before] anchor element name(s) - position
24119
+ * the group just before the most-back anchor
24120
+ * @property {string | Array<string>} [after] anchor element name(s) - position
24121
+ * the group just after the most-front anchor
24122
+ * @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
24123
+ *
24124
+ * @see To test examples, append them to the
24125
+ * <a href="#drawing-boilerplate">boilerplate</a>
24126
+ *
24127
+ * @example
24128
+ * // Three overlapping squares, offset so the stacking order is visible. Blue
24129
+ * // is defined last so it sits on top by default; `back` sends it behind the
24130
+ * // red and green squares (so green ends up on top).
24131
+ * const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
24132
+ * figure.add({
24133
+ * make: 'equation',
24134
+ * elements: {
24135
+ * r: sq([1, 0, 0, 1]),
24136
+ * g: sq([0, 0.8, 0, 1]),
24137
+ * b: sq([0, 0, 1, 1]),
24138
+ * },
24139
+ * forms: {
24140
+ * 0: [
24141
+ * { offset: ['r', [0, 0]] },
24142
+ * { offset: ['g', [0.3, -0.25]] },
24143
+ * { offset: [{ back: ['b'] }, [0.6, -0.5]] },
24144
+ * ],
24145
+ * },
24146
+ * });
24147
+ *
24148
+ * @example
24149
+ * // Object Definition with an anchor - position the blue square just before
24150
+ * // (behind) the red square, so red and green sit on top of it.
24151
+ * const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
24152
+ * figure.add({
24153
+ * make: 'equation',
24154
+ * elements: {
24155
+ * r: sq([1, 0, 0, 1]),
24156
+ * g: sq([0, 0.8, 0, 1]),
24157
+ * b: sq([0, 0, 1, 1]),
24158
+ * },
24159
+ * forms: {
24160
+ * 0: [
24161
+ * { offset: ['r', [0, 0]] },
24162
+ * { offset: ['g', [0.3, -0.25]] },
24163
+ * { offset: [{ back: { content: 'b', before: 'r' } }, [0.6, -0.5]] },
24164
+ * ],
24165
+ * },
24166
+ * });
24167
+ *
24168
+ * @interface
24169
+ * @group Equation Layout
24170
+ */
24171
+
24172
+ /**
24173
+ * Equation front function
24174
+ *
24175
+ * Bring an equation phrase's elements forward in the equation's draw stack. All
24176
+ * elements within `content` are moved together as a group, keeping their
24177
+ * current relative draw order. Nested `front`/`back` functions are applied
24178
+ * inner-most first, so an inner `front`/`back` reorders the elements and this
24179
+ * (outer) function then moves the reordered group as a unit.
24180
+ *
24181
+ * The group's position is determined by, in order of precedence:
24182
+ * - `before` - position the group just before (behind) the most-back of the
24183
+ * named anchor element(s). `num` shifts it further back (default `0`).
24184
+ * - `after` - position the group just after (in front of) the most-front of
24185
+ * the named anchor element(s). `num` shifts it further forward (default `0`).
24186
+ * - `num` - a positive value moves the group that many places forward; a
24187
+ * negative value positions it `|num|` places behind the very front.
24188
+ * - otherwise the group is brought completely to the front.
24189
+ *
24190
+ * The reorder is applied whenever the form is shown, relative to the equation's
24191
+ * natural (definition) draw order, so each form deterministically defines its
24192
+ * own stacking.
24193
+ *
24194
+ * Options can be an object, or an array in the property order below
24195
+ *
24196
+ * @property {TypeEquationPhrase} content
24197
+ * @property {number} [num] places to bring the group forward (positive), or an
24198
+ * absolute position `|num|` places behind the full front (negative). When
24199
+ * `before`/`after` is set, `num` is the offset from the anchor (default `0`).
24200
+ * If undefined (and no anchor), the group is brought completely to the front
24201
+ * @property {string | Array<string>} [before] anchor element name(s) - position
24202
+ * the group just before the most-back anchor
24203
+ * @property {string | Array<string>} [after] anchor element name(s) - position
24204
+ * the group just after the most-front anchor
24205
+ * @property {boolean} [fullContentBounds] Use full bounds with content (`false`)
24206
+ *
24207
+ * @see To test examples, append them to the
24208
+ * <a href="#drawing-boilerplate">boilerplate</a>
24209
+ *
24210
+ * @example
24211
+ * // Three overlapping squares, offset so the stacking order is visible. Red is
24212
+ * // defined first so it sits at the back by default; `front` brings it on top
24213
+ * // of the green and blue squares.
24214
+ * const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
24215
+ * figure.add({
24216
+ * make: 'equation',
24217
+ * elements: {
24218
+ * r: sq([1, 0, 0, 1]),
24219
+ * g: sq([0, 0.8, 0, 1]),
24220
+ * b: sq([0, 0, 1, 1]),
24221
+ * },
24222
+ * forms: {
24223
+ * 0: [
24224
+ * { offset: [{ front: ['r'] }, [0, 0]] },
24225
+ * { offset: ['g', [0.3, -0.25]] },
24226
+ * { offset: ['b', [0.6, -0.5]] },
24227
+ * ],
24228
+ * },
24229
+ * });
24230
+ *
24231
+ * @example
24232
+ * // Object Definition with an anchor - position the red square just after (in
24233
+ * // front of) the green square, so it covers green but stays behind blue.
24234
+ * const sq = color => figure.primitives.rectangle({ width: 0.6, height: 0.6, color });
24235
+ * figure.add({
24236
+ * make: 'equation',
24237
+ * elements: {
24238
+ * r: sq([1, 0, 0, 1]),
24239
+ * g: sq([0, 0.8, 0, 1]),
24240
+ * b: sq([0, 0, 1, 1]),
24241
+ * },
24242
+ * forms: {
24243
+ * 0: [
24244
+ * { offset: [{ front: { content: 'r', after: 'g' } }, [0, 0]] },
24245
+ * { offset: ['g', [0.3, -0.25]] },
24246
+ * { offset: ['b', [0.6, -0.5]] },
24247
+ * ],
24248
+ * },
24249
+ * });
24250
+ *
23445
24251
  * @interface
23446
24252
  * @group Equation Layout
23447
24253
  */
@@ -25848,6 +26654,15 @@ var EquationFunctions = /*#__PURE__*/function () {
25848
26654
  if (name === 'color') {
25849
26655
  return this.color(params);
25850
26656
  }
26657
+ if (name === 'opacity') {
26658
+ return this.opacity(params);
26659
+ }
26660
+ if (name === 'back') {
26661
+ return this.back(params);
26662
+ }
26663
+ if (name === 'front') {
26664
+ return this.front(params);
26665
+ }
25851
26666
  return null;
25852
26667
  }
25853
26668
 
@@ -26473,6 +27288,108 @@ var EquationFunctions = /*#__PURE__*/function () {
26473
27288
  }
26474
27289
  }
26475
27290
 
27291
+ /**
27292
+ * Equation opacity function
27293
+ * @see {@link EQN_Opacity} for description and examples
27294
+ */
27295
+ }, {
27296
+ key: "opacity",
27297
+ value: function opacity(options) {
27298
+ try {
27299
+ var content;
27300
+ var _opacity;
27301
+ var fullContentBounds;
27302
+ var defaultOptions = {
27303
+ opacity: null,
27304
+ fullContentBounds: false
27305
+ };
27306
+ if (Array.isArray(options)) {
27307
+ var _options6 = _slicedToArray(options, 3);
27308
+ content = _options6[0];
27309
+ _opacity = _options6[1];
27310
+ fullContentBounds = _options6[2];
27311
+ } else {
27312
+ content = options.content;
27313
+ _opacity = options.opacity;
27314
+ fullContentBounds = options.fullContentBounds;
27315
+ }
27316
+ var optionsIn = {
27317
+ opacity: _opacity,
27318
+ fullContentBounds: fullContentBounds
27319
+ };
27320
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_1__.joinObjects)(defaultOptions, optionsIn);
27321
+ return new _Elements_Opacity__WEBPACK_IMPORTED_MODULE_14__["default"]([this.contentToElement(content)], [], o);
27322
+ } catch (e) {
27323
+ throw new Error("FigureOne Equation Opacity Error: ".concat(e.message));
27324
+ }
27325
+ }
27326
+
27327
+ /**
27328
+ * Equation back function
27329
+ * @see {@link EQN_Back} for description and examples
27330
+ */
27331
+ }, {
27332
+ key: "back",
27333
+ value: function back(options) {
27334
+ try {
27335
+ return this.drawOrder(options, false);
27336
+ } catch (e) {
27337
+ throw new Error("FigureOne Equation Back Error: ".concat(e.message));
27338
+ }
27339
+ }
27340
+
27341
+ /**
27342
+ * Equation front function
27343
+ * @see {@link EQN_Front} for description and examples
27344
+ */
27345
+ }, {
27346
+ key: "front",
27347
+ value: function front(options) {
27348
+ try {
27349
+ return this.drawOrder(options, true);
27350
+ } catch (e) {
27351
+ throw new Error("FigureOne Equation Front Error: ".concat(e.message));
27352
+ }
27353
+ }
27354
+
27355
+ // Shared implementation for the `front`/`back` equation functions.
27356
+ }, {
27357
+ key: "drawOrder",
27358
+ value: function drawOrder(options, front) {
27359
+ var content;
27360
+ var num;
27361
+ var fullContentBounds;
27362
+ var before;
27363
+ var after;
27364
+ var defaultOptions = {
27365
+ num: null,
27366
+ fullContentBounds: false,
27367
+ before: null,
27368
+ after: null
27369
+ };
27370
+ if (Array.isArray(options)) {
27371
+ var _options7 = _slicedToArray(options, 3);
27372
+ content = _options7[0];
27373
+ num = _options7[1];
27374
+ fullContentBounds = _options7[2];
27375
+ } else {
27376
+ content = options.content;
27377
+ num = options.num;
27378
+ fullContentBounds = options.fullContentBounds;
27379
+ before = options.before;
27380
+ after = options.after;
27381
+ }
27382
+ var optionsIn = {
27383
+ num: num,
27384
+ fullContentBounds: fullContentBounds,
27385
+ front: front,
27386
+ before: before,
27387
+ after: after
27388
+ };
27389
+ var o = (0,_tools_tools__WEBPACK_IMPORTED_MODULE_1__.joinObjects)(defaultOptions, optionsIn);
27390
+ return new _Elements_DrawOrder__WEBPACK_IMPORTED_MODULE_15__["default"]([this.contentToElement(content)], [], o);
27391
+ }
27392
+
26476
27393
  /**
26477
27394
  * Equation fraction function
26478
27395
  * @see {@link EQN_Fraction} for description and examples
@@ -26507,17 +27424,17 @@ var EquationFunctions = /*#__PURE__*/function () {
26507
27424
  baseline: 'vinculum'
26508
27425
  };
26509
27426
  if (Array.isArray(options)) {
26510
- var _options6 = _slicedToArray(options, 10);
26511
- numerator = _options6[0];
26512
- symbol = _options6[1];
26513
- denominator = _options6[2];
26514
- scale = _options6[3];
26515
- numeratorSpace = _options6[4];
26516
- denominatorSpace = _options6[5];
26517
- overhang = _options6[6];
26518
- offsetY = _options6[7];
26519
- baseline = _options6[8];
26520
- fullContentBounds = _options6[9];
27427
+ var _options8 = _slicedToArray(options, 10);
27428
+ numerator = _options8[0];
27429
+ symbol = _options8[1];
27430
+ denominator = _options8[2];
27431
+ scale = _options8[3];
27432
+ numeratorSpace = _options8[4];
27433
+ denominatorSpace = _options8[5];
27434
+ overhang = _options8[6];
27435
+ offsetY = _options8[7];
27436
+ baseline = _options8[8];
27437
+ fullContentBounds = _options8[9];
26521
27438
  } else {
26522
27439
  numerator = options.numerator;
26523
27440
  symbol = options.symbol;
@@ -26662,14 +27579,14 @@ var EquationFunctions = /*#__PURE__*/function () {
26662
27579
  var superscriptOffset = null;
26663
27580
  var inSize;
26664
27581
  if (Array.isArray(options)) {
26665
- var _options7 = _slicedToArray(options, 7);
26666
- content = _options7[0];
26667
- superscript = _options7[1];
26668
- subscript = _options7[2];
26669
- scale = _options7[3];
26670
- superscriptOffset = _options7[4];
26671
- subscriptOffset = _options7[5];
26672
- inSize = _options7[6];
27582
+ var _options9 = _slicedToArray(options, 7);
27583
+ content = _options9[0];
27584
+ superscript = _options9[1];
27585
+ subscript = _options9[2];
27586
+ scale = _options9[3];
27587
+ superscriptOffset = _options9[4];
27588
+ subscriptOffset = _options9[5];
27589
+ inSize = _options9[6];
26673
27590
  } else {
26674
27591
  content = options.content;
26675
27592
  superscript = options.superscript;
@@ -26739,12 +27656,12 @@ var EquationFunctions = /*#__PURE__*/function () {
26739
27656
  // let superscriptOffset = null;
26740
27657
  var inSize;
26741
27658
  if (Array.isArray(options)) {
26742
- var _options8 = _slicedToArray(options, 5);
26743
- content = _options8[0];
26744
- superscript = _options8[1];
26745
- scale = _options8[2];
26746
- offset = _options8[3];
26747
- inSize = _options8[4];
27659
+ var _options0 = _slicedToArray(options, 5);
27660
+ content = _options0[0];
27661
+ superscript = _options0[1];
27662
+ scale = _options0[2];
27663
+ offset = _options0[3];
27664
+ inSize = _options0[4];
26748
27665
  } else {
26749
27666
  content = options.content;
26750
27667
  superscript = options.superscript;
@@ -26778,12 +27695,12 @@ var EquationFunctions = /*#__PURE__*/function () {
26778
27695
  var offset;
26779
27696
  var inSize;
26780
27697
  if (Array.isArray(options)) {
26781
- var _options9 = _slicedToArray(options, 5);
26782
- content = _options9[0];
26783
- subscript = _options9[1];
26784
- scale = _options9[2];
26785
- offset = _options9[3];
26786
- inSize = _options9[4];
27698
+ var _options1 = _slicedToArray(options, 5);
27699
+ content = _options1[0];
27700
+ subscript = _options1[1];
27701
+ scale = _options1[2];
27702
+ offset = _options1[3];
27703
+ inSize = _options1[4];
26787
27704
  } else {
26788
27705
  content = options.content;
26789
27706
  subscript = options.subscript;
@@ -26827,14 +27744,14 @@ var EquationFunctions = /*#__PURE__*/function () {
26827
27744
  rightSpace: null
26828
27745
  };
26829
27746
  if (Array.isArray(options)) {
26830
- var _options0 = _slicedToArray(options, 7);
26831
- content = _options0[0];
26832
- symbol = _options0[1];
26833
- space = _options0[2];
26834
- topSpace = _options0[3];
26835
- rightSpace = _options0[4];
26836
- bottomSpace = _options0[5];
26837
- leftSpace = _options0[6];
27747
+ var _options10 = _slicedToArray(options, 7);
27748
+ content = _options10[0];
27749
+ symbol = _options10[1];
27750
+ space = _options10[2];
27751
+ topSpace = _options10[3];
27752
+ rightSpace = _options10[4];
27753
+ bottomSpace = _options10[5];
27754
+ leftSpace = _options10[6];
26838
27755
  } else {
26839
27756
  content = options.content;
26840
27757
  symbol = options.symbol;
@@ -26904,17 +27821,17 @@ var EquationFunctions = /*#__PURE__*/function () {
26904
27821
  useFullBounds: false
26905
27822
  };
26906
27823
  if (Array.isArray(options)) {
26907
- var _options1 = _slicedToArray(options, 10);
26908
- content = _options1[0];
26909
- symbol = _options1[1];
26910
- inSize = _options1[2];
26911
- space = _options1[3];
26912
- topSpace = _options1[4];
26913
- rightSpace = _options1[5];
26914
- bottomSpace = _options1[6];
26915
- leftSpace = _options1[7];
26916
- fullContentBounds = _options1[8];
26917
- useFullBounds = _options1[9];
27824
+ var _options11 = _slicedToArray(options, 10);
27825
+ content = _options11[0];
27826
+ symbol = _options11[1];
27827
+ inSize = _options11[2];
27828
+ space = _options11[3];
27829
+ topSpace = _options11[4];
27830
+ rightSpace = _options11[5];
27831
+ bottomSpace = _options11[6];
27832
+ leftSpace = _options11[7];
27833
+ fullContentBounds = _options11[8];
27834
+ useFullBounds = _options11[9];
26918
27835
  } else {
26919
27836
  content = options.content;
26920
27837
  symbol = options.symbol;
@@ -26981,12 +27898,12 @@ var EquationFunctions = /*#__PURE__*/function () {
26981
27898
  bottom: 0
26982
27899
  };
26983
27900
  if (Array.isArray(options)) {
26984
- var _options10 = _slicedToArray(options, 5);
26985
- content = _options10[0];
26986
- top = _options10[1];
26987
- right = _options10[2];
26988
- bottom = _options10[3];
26989
- left = _options10[4];
27901
+ var _options12 = _slicedToArray(options, 5);
27902
+ content = _options12[0];
27903
+ top = _options12[1];
27904
+ right = _options12[2];
27905
+ bottom = _options12[3];
27906
+ left = _options12[4];
26990
27907
  } else {
26991
27908
  content = options.content;
26992
27909
  top = options.top;
@@ -27073,17 +27990,17 @@ var EquationFunctions = /*#__PURE__*/function () {
27073
27990
  fullContentBounds: false
27074
27991
  };
27075
27992
  if (Array.isArray(options)) {
27076
- var _options11 = _slicedToArray(options, 10);
27077
- order = _options11[0];
27078
- left = _options11[1];
27079
- content = _options11[2];
27080
- right = _options11[3];
27081
- scale = _options11[4];
27082
- fit = _options11[5];
27083
- space = _options11[6];
27084
- yAlign = _options11[7];
27085
- brac = _options11[8];
27086
- fullContentBounds = _options11[9];
27993
+ var _options13 = _slicedToArray(options, 10);
27994
+ order = _options13[0];
27995
+ left = _options13[1];
27996
+ content = _options13[2];
27997
+ right = _options13[3];
27998
+ scale = _options13[4];
27999
+ fit = _options13[5];
28000
+ space = _options13[6];
28001
+ yAlign = _options13[7];
28002
+ brac = _options13[8];
28003
+ fullContentBounds = _options13[9];
27087
28004
  } else {
27088
28005
  order = options.order;
27089
28006
  left = options.left;
@@ -27156,13 +28073,13 @@ var EquationFunctions = /*#__PURE__*/function () {
27156
28073
  fullContentBounds: false
27157
28074
  };
27158
28075
  if (Array.isArray(options)) {
27159
- var _options12 = _slicedToArray(options, 6);
27160
- content = _options12[0];
27161
- justify = _options12[1];
27162
- baselineSpace = _options12[2];
27163
- space = _options12[3];
27164
- yAlign = _options12[4];
27165
- fullContentBounds = _options12[5];
28076
+ var _options14 = _slicedToArray(options, 6);
28077
+ content = _options14[0];
28078
+ justify = _options14[1];
28079
+ baselineSpace = _options14[2];
28080
+ space = _options14[3];
28081
+ yAlign = _options14[4];
28082
+ fullContentBounds = _options14[5];
27166
28083
  } else {
27167
28084
  content = options.content;
27168
28085
  justify = options.justify;
@@ -27280,34 +28197,34 @@ var EquationFunctions = /*#__PURE__*/function () {
27280
28197
  useFullBounds: false
27281
28198
  };
27282
28199
  if (Array.isArray(options)) {
27283
- var _options13 = _slicedToArray(options, 27);
27284
- symbol = _options13[0];
27285
- content = _options13[1];
27286
- from = _options13[2];
27287
- to = _options13[3];
27288
- inSize = _options13[4];
27289
- space = _options13[5];
27290
- topSpace = _options13[6];
27291
- bottomSpace = _options13[7];
27292
- height = _options13[8];
27293
- yOffset = _options13[9];
27294
- scale = _options13[10];
27295
- fromScale = _options13[11];
27296
- toScale = _options13[12];
27297
- fromOffset = _options13[13];
27298
- toOffset = _options13[14];
27299
- limitsPosition = _options13[15];
27300
- limitsAroundContent = _options13[16];
27301
- fromXPosition = _options13[17];
27302
- fromYPosition = _options13[18];
27303
- fromXAlign = _options13[19];
27304
- fromYAlign = _options13[20];
27305
- toXPosition = _options13[21];
27306
- toYPosition = _options13[22];
27307
- toXAlign = _options13[23];
27308
- toYAlign = _options13[24];
27309
- fullBoundsContent = _options13[25];
27310
- useFullBounds = _options13[26];
28200
+ var _options15 = _slicedToArray(options, 27);
28201
+ symbol = _options15[0];
28202
+ content = _options15[1];
28203
+ from = _options15[2];
28204
+ to = _options15[3];
28205
+ inSize = _options15[4];
28206
+ space = _options15[5];
28207
+ topSpace = _options15[6];
28208
+ bottomSpace = _options15[7];
28209
+ height = _options15[8];
28210
+ yOffset = _options15[9];
28211
+ scale = _options15[10];
28212
+ fromScale = _options15[11];
28213
+ toScale = _options15[12];
28214
+ fromOffset = _options15[13];
28215
+ toOffset = _options15[14];
28216
+ limitsPosition = _options15[15];
28217
+ limitsAroundContent = _options15[16];
28218
+ fromXPosition = _options15[17];
28219
+ fromYPosition = _options15[18];
28220
+ fromXAlign = _options15[19];
28221
+ fromYAlign = _options15[20];
28222
+ toXPosition = _options15[21];
28223
+ toYPosition = _options15[22];
28224
+ toXAlign = _options15[23];
28225
+ toYAlign = _options15[24];
28226
+ fullBoundsContent = _options15[25];
28227
+ useFullBounds = _options15[26];
27311
28228
  } else {
27312
28229
  content = options.content;
27313
28230
  symbol = options.symbol;
@@ -27856,17 +28773,17 @@ var EquationFunctions = /*#__PURE__*/function () {
27856
28773
  useFullBounds: false
27857
28774
  };
27858
28775
  if (Array.isArray(options)) {
27859
- var _options14 = _slicedToArray(options, 10);
27860
- content = _options14[0];
27861
- symbol = _options14[1];
27862
- inSize = _options14[2];
27863
- space = _options14[3];
27864
- topSpace = _options14[4];
27865
- rightSpace = _options14[5];
27866
- bottomSpace = _options14[6];
27867
- leftSpace = _options14[7];
27868
- fullContentBounds = _options14[8];
27869
- useFullBounds = _options14[9];
28776
+ var _options16 = _slicedToArray(options, 10);
28777
+ content = _options16[0];
28778
+ symbol = _options16[1];
28779
+ inSize = _options16[2];
28780
+ space = _options16[3];
28781
+ topSpace = _options16[4];
28782
+ rightSpace = _options16[5];
28783
+ bottomSpace = _options16[6];
28784
+ leftSpace = _options16[7];
28785
+ fullContentBounds = _options16[8];
28786
+ useFullBounds = _options16[9];
27870
28787
  } else {
27871
28788
  content = options.content;
27872
28789
  symbol = options.symbol;
@@ -51728,7 +52645,11 @@ var FigureElementPrimitive2DText = /*#__PURE__*/function (_FigureElementPrimiti)
51728
52645
  key: "setColor",
51729
52646
  value: function setColor(color) {
51730
52647
  var setDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
51731
- _superPropGet(FigureElementPrimitive2DText, "setColor", this, 3)([color, setDefault]);
52648
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
52649
+ if (this.isSetColorIgnored(from)) {
52650
+ return;
52651
+ }
52652
+ _superPropGet(FigureElementPrimitive2DText, "setColor", this, 3)([color, setDefault, from]);
51732
52653
  this.drawingObject.font.color = color.slice();
51733
52654
  }
51734
52655
  }, {
@@ -52197,7 +53118,11 @@ var FigureElementPrimitiveGLText = /*#__PURE__*/function (_FigureElementPrimiti)
52197
53118
  key: "setColor",
52198
53119
  value: function setColor(color) {
52199
53120
  var setDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
52200
- _superPropGet(FigureElementPrimitiveGLText, "setColor", this, 3)([color, setDefault]);
53121
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
53122
+ if (this.isSetColorIgnored(from)) {
53123
+ return;
53124
+ }
53125
+ _superPropGet(FigureElementPrimitiveGLText, "setColor", this, 3)([color, setDefault, from]);
52201
53126
  this.font.color = color.slice();
52202
53127
  }
52203
53128
  }, {
@@ -80920,8 +81845,8 @@ var tools = {
80920
81845
  */
80921
81846
 
80922
81847
  var Fig = {
80923
- version: "1.5.0",
80924
- gitHash: "2390662f6",
81848
+ version: "1.7.0",
81849
+ gitHash: "8c04ba173",
80925
81850
  tools: tools,
80926
81851
  Figure: _js_figure_Figure__WEBPACK_IMPORTED_MODULE_5__["default"],
80927
81852
  Recorder: _js_figure_Recorder_Recorder__WEBPACK_IMPORTED_MODULE_7__.Recorder,