Use the MathClamp helper function more (PR 19617 follow-up)
There's a few spots that I accidentally missed in PR 19617.
This commit is contained in:
parent
af89e77124
commit
bee0f53c65
@ -18,6 +18,7 @@ import {
|
|||||||
FormatError,
|
FormatError,
|
||||||
IDENTITY_MATRIX,
|
IDENTITY_MATRIX,
|
||||||
info,
|
info,
|
||||||
|
MathClamp,
|
||||||
unreachable,
|
unreachable,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
@ -843,17 +844,19 @@ class MeshShading extends BaseShading {
|
|||||||
((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY) /
|
((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY) /
|
||||||
(this.bounds[2] - this.bounds[0])
|
(this.bounds[2] - this.bounds[0])
|
||||||
);
|
);
|
||||||
splitXBy = Math.max(
|
splitXBy = MathClamp(
|
||||||
|
splitXBy,
|
||||||
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
||||||
Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy)
|
MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT
|
||||||
);
|
);
|
||||||
let splitYBy = Math.ceil(
|
let splitYBy = Math.ceil(
|
||||||
((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY) /
|
((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY) /
|
||||||
(this.bounds[3] - this.bounds[1])
|
(this.bounds[3] - this.bounds[1])
|
||||||
);
|
);
|
||||||
splitYBy = Math.max(
|
splitYBy = MathClamp(
|
||||||
|
splitYBy,
|
||||||
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
|
||||||
Math.min(MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy)
|
MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT
|
||||||
);
|
);
|
||||||
|
|
||||||
const verticesPerRow = splitXBy + 1;
|
const verticesPerRow = splitXBy + 1;
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import {
|
|||||||
$isSplittable,
|
$isSplittable,
|
||||||
$isThereMoreWidth,
|
$isThereMoreWidth,
|
||||||
} from "./symbol_utils.js";
|
} from "./symbol_utils.js";
|
||||||
|
import { MathClamp } from "../../shared/util.js";
|
||||||
import { measureToString } from "./html_utils.js";
|
import { measureToString } from "./html_utils.js";
|
||||||
|
|
||||||
// Subform and ExclGroup have a layout so they share these functions.
|
// Subform and ExclGroup have a layout so they share these functions.
|
||||||
@ -141,7 +142,7 @@ function addHTML(node, html, bbox) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "table": {
|
case "table": {
|
||||||
extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
|
extra.width = MathClamp(w, extra.width, availableSpace.width);
|
||||||
extra.height += h;
|
extra.height += h;
|
||||||
extra.children.push(html);
|
extra.children.push(html);
|
||||||
break;
|
break;
|
||||||
@ -150,7 +151,7 @@ function addHTML(node, html, bbox) {
|
|||||||
// Even if the subform can possibly take all the available width,
|
// Even if the subform can possibly take all the available width,
|
||||||
// we must compute the final width as it is in order to be able
|
// we must compute the final width as it is in order to be able
|
||||||
// for example to center the subform within its parent.
|
// for example to center the subform within its parent.
|
||||||
extra.width = Math.min(availableSpace.width, Math.max(extra.width, w));
|
extra.width = MathClamp(w, extra.width, availableSpace.width);
|
||||||
extra.height += h;
|
extra.height += h;
|
||||||
extra.children.push(html);
|
extra.children.push(html);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user