manim-web 0.3.0 → 0.3.1
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/dist/index.js
CHANGED
|
@@ -37116,6 +37116,7 @@ class Zo extends Mt {
|
|
|
37116
37116
|
_svgFillOpacity;
|
|
37117
37117
|
_targetHeight;
|
|
37118
37118
|
_macros;
|
|
37119
|
+
_svgViewBoxWidth = 1e3;
|
|
37119
37120
|
/** Whether this is a multi-part MathTexSVG (created from string[]) */
|
|
37120
37121
|
_isMultiPart = !1;
|
|
37121
37122
|
/** Child part groups (only when _isMultiPart is true) */
|
|
@@ -37150,7 +37151,9 @@ class Zo extends Mt {
|
|
|
37150
37151
|
*/
|
|
37151
37152
|
getPart(t) {
|
|
37152
37153
|
if (!this._isMultiPart)
|
|
37153
|
-
throw new Error(
|
|
37154
|
+
throw new Error(
|
|
37155
|
+
"getPart() is only available on multi-part MathTexSVG (created with string[])"
|
|
37156
|
+
);
|
|
37154
37157
|
if (t < 0 || t >= this._parts.length)
|
|
37155
37158
|
throw new Error(`Part index ${t} out of range [0, ${this._parts.length - 1}]`);
|
|
37156
37159
|
return this._parts[t];
|
|
@@ -37195,15 +37198,20 @@ class Zo extends Mt {
|
|
|
37195
37198
|
* Render the LaTeX to VMobject paths.
|
|
37196
37199
|
*/
|
|
37197
37200
|
async _render() {
|
|
37198
|
-
const
|
|
37201
|
+
const t = await Hr(this._latex, {
|
|
37199
37202
|
displayMode: this._displayMode,
|
|
37200
37203
|
color: this._color,
|
|
37201
37204
|
fontScale: this._fontSize,
|
|
37202
37205
|
macros: this._macros
|
|
37203
|
-
}))
|
|
37204
|
-
|
|
37205
|
-
|
|
37206
|
-
|
|
37206
|
+
}), e = t.svgElement.getAttribute?.("viewBox");
|
|
37207
|
+
if (e) {
|
|
37208
|
+
const r = e.split(/\s+/).map(Number);
|
|
37209
|
+
this._svgViewBoxWidth = r[2] || 1e3;
|
|
37210
|
+
}
|
|
37211
|
+
const i = t.vmobjectGroup;
|
|
37212
|
+
this._restyleChildren(i);
|
|
37213
|
+
for (const r of [...i.children])
|
|
37214
|
+
i.remove(r), this.add(r);
|
|
37207
37215
|
this._scaleToTarget(), this.fillOpacity = this._svgFillOpacity;
|
|
37208
37216
|
}
|
|
37209
37217
|
/**
|
|
@@ -37221,26 +37229,24 @@ class Zo extends Mt {
|
|
|
37221
37229
|
* Scale and center the assembled paths by transforming actual point data.
|
|
37222
37230
|
*/
|
|
37223
37231
|
_scaleToTarget() {
|
|
37224
|
-
const t = [], e = (
|
|
37225
|
-
if (
|
|
37226
|
-
for (const
|
|
37227
|
-
e(
|
|
37232
|
+
const t = [], e = (u) => {
|
|
37233
|
+
if (u instanceof B && !(u instanceof Mt) && t.push(u), "children" in u)
|
|
37234
|
+
for (const d of u.children)
|
|
37235
|
+
e(d);
|
|
37228
37236
|
};
|
|
37229
37237
|
e(this);
|
|
37230
37238
|
let i = 1 / 0, r = -1 / 0, n = 1 / 0, o = -1 / 0;
|
|
37231
|
-
for (const
|
|
37232
|
-
for (const
|
|
37233
|
-
|
|
37239
|
+
for (const u of t)
|
|
37240
|
+
for (const d of u.getPoints())
|
|
37241
|
+
d[0] < i && (i = d[0]), d[0] > r && (r = d[0]), d[1] < n && (n = d[1]), d[1] > o && (o = d[1]);
|
|
37234
37242
|
const a = o - n;
|
|
37235
37243
|
if (a < 1e-4) return;
|
|
37236
|
-
|
|
37237
|
-
|
|
37238
|
-
|
|
37239
|
-
|
|
37240
|
-
|
|
37241
|
-
|
|
37242
|
-
]);
|
|
37243
|
-
d.setPoints3D(g);
|
|
37244
|
+
let h;
|
|
37245
|
+
this._targetHeight !== void 0 ? h = this._targetHeight / a : h = 0.5 * this._svgViewBoxWidth / 1e3;
|
|
37246
|
+
const l = (i + r) / 2, c = (n + o) / 2;
|
|
37247
|
+
for (const u of t) {
|
|
37248
|
+
const f = u.getPoints().map((g) => [(g[0] - l) * h, (g[1] - c) * h, g[2]]);
|
|
37249
|
+
u.setPoints3D(f);
|
|
37244
37250
|
}
|
|
37245
37251
|
}
|
|
37246
37252
|
/**
|
|
@@ -37255,38 +37261,42 @@ class Zo extends Mt {
|
|
|
37255
37261
|
color: this._color,
|
|
37256
37262
|
fontScale: this._fontSize,
|
|
37257
37263
|
macros: this._macros
|
|
37258
|
-
});
|
|
37264
|
+
}), r = i.svgElement.getAttribute?.("viewBox");
|
|
37265
|
+
if (r) {
|
|
37266
|
+
const h = r.split(/\s+/).map(Number);
|
|
37267
|
+
this._svgViewBoxWidth = h[2] || 1e3;
|
|
37268
|
+
}
|
|
37259
37269
|
this._restyleChildren(i.vmobjectGroup);
|
|
37260
|
-
const r = [];
|
|
37261
|
-
for (const a of [...i.vmobjectGroup.children])
|
|
37262
|
-
a instanceof B && r.push(a);
|
|
37263
37270
|
const n = [];
|
|
37264
|
-
for (const
|
|
37265
|
-
|
|
37271
|
+
for (const h of [...i.vmobjectGroup.children])
|
|
37272
|
+
h instanceof B && n.push(h);
|
|
37273
|
+
const o = [];
|
|
37274
|
+
for (const h of t) {
|
|
37275
|
+
const l = await Hr(h, {
|
|
37266
37276
|
displayMode: !1,
|
|
37267
37277
|
color: this._color,
|
|
37268
37278
|
fontScale: this._fontSize,
|
|
37269
37279
|
macros: this._macros
|
|
37270
37280
|
});
|
|
37271
|
-
let
|
|
37272
|
-
for (const
|
|
37273
|
-
|
|
37274
|
-
|
|
37281
|
+
let c = 0;
|
|
37282
|
+
for (const u of l.vmobjectGroup.children)
|
|
37283
|
+
u instanceof B && c++;
|
|
37284
|
+
o.push(c);
|
|
37275
37285
|
}
|
|
37276
|
-
let
|
|
37277
|
-
for (let
|
|
37278
|
-
const
|
|
37279
|
-
|
|
37280
|
-
const
|
|
37281
|
-
for (let
|
|
37282
|
-
const
|
|
37283
|
-
i.vmobjectGroup.remove(
|
|
37284
|
-
}
|
|
37285
|
-
this._parts.push(
|
|
37286
|
-
}
|
|
37287
|
-
for (;
|
|
37288
|
-
const
|
|
37289
|
-
i.vmobjectGroup.remove(
|
|
37286
|
+
let a = 0;
|
|
37287
|
+
for (let h = 0; h < t.length; h++) {
|
|
37288
|
+
const l = new Zo._PartGroup(this);
|
|
37289
|
+
l._latex = t[h], l._color = this._color;
|
|
37290
|
+
const c = o[h];
|
|
37291
|
+
for (let u = 0; u < c && a < n.length; u++) {
|
|
37292
|
+
const d = n[a++];
|
|
37293
|
+
i.vmobjectGroup.remove(d), l.add(d);
|
|
37294
|
+
}
|
|
37295
|
+
this._parts.push(l), this.add(l);
|
|
37296
|
+
}
|
|
37297
|
+
for (; a < n.length; ) {
|
|
37298
|
+
const h = this._parts[this._parts.length - 1], l = n[a++];
|
|
37299
|
+
i.vmobjectGroup.remove(l), h.add(l);
|
|
37290
37300
|
}
|
|
37291
37301
|
this._scaleToTarget(), this.fillOpacity = this._svgFillOpacity;
|
|
37292
37302
|
}
|
|
@@ -29,6 +29,7 @@ export declare class MathTexSVG extends VGroup {
|
|
|
29
29
|
protected _svgFillOpacity: number;
|
|
30
30
|
protected _targetHeight: number | undefined;
|
|
31
31
|
protected _macros: Record<string, string> | undefined;
|
|
32
|
+
protected _svgViewBoxWidth: number;
|
|
32
33
|
/** Whether this is a multi-part MathTexSVG (created from string[]) */
|
|
33
34
|
protected _isMultiPart: boolean;
|
|
34
35
|
/** Child part groups (only when _isMultiPart is true) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MathTexSVG.d.ts","sourceRoot":"","sources":["../../../src/mobjects/text/MathTexSVG.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAW,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIhE,MAAM,WAAW,iBAAiB;IAChC,mEAAmE;IACnE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,QAAQ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