Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/core/pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
FormatError,
info,
MathClamp,
MeshFigureType,
unreachable,
Util,
warn,
Expand Down Expand Up @@ -582,7 +583,7 @@ class MeshShading extends BaseShading {
reader.align();
}
this.figures.push({
type: "triangles",
type: MeshFigureType.TRIANGLES,
coords: new Int32Array(ps),
colors: new Int32Array(ps),
});
Expand All @@ -600,7 +601,7 @@ class MeshShading extends BaseShading {
colors.push(color);
}
this.figures.push({
type: "lattice",
type: MeshFigureType.LATTICE,
coords: new Int32Array(ps),
colors: new Int32Array(ps),
verticesPerRow,
Expand Down Expand Up @@ -732,7 +733,7 @@ class MeshShading extends BaseShading {
9,
]);
this.figures.push({
type: "patch",
type: MeshFigureType.PATCH,
coords: new Int32Array(ps), // making copies of ps and cs
colors: new Int32Array(cs),
});
Expand Down Expand Up @@ -802,7 +803,7 @@ class MeshShading extends BaseShading {
break;
}
this.figures.push({
type: "patch",
type: MeshFigureType.PATCH,
coords: new Int32Array(ps), // making copies of ps and cs
colors: new Int32Array(cs),
});
Expand All @@ -811,7 +812,10 @@ class MeshShading extends BaseShading {

_buildFigureFromPatch(index) {
const figure = this.figures[index];
assert(figure.type === "patch", "Unexpected patch mesh figure");
assert(
figure.type === MeshFigureType.PATCH,
"Unexpected patch mesh figure"
);

const coords = this.coords,
colors = this.colors;
Expand Down Expand Up @@ -919,7 +923,7 @@ class MeshShading extends BaseShading {
figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];

this.figures[index] = {
type: "lattice",
type: MeshFigureType.LATTICE,
coords: figureCoords,
colors: figureColors,
verticesPerRow,
Expand Down
12 changes: 9 additions & 3 deletions src/display/pattern_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
* limitations under the License.
*/

import { FormatError, info, unreachable, Util } from "../shared/util.js";
import {
FormatError,
info,
MeshFigureType,
unreachable,
Util,
} from "../shared/util.js";
import { getCurrentTransform } from "./display_utils.js";

const PathType = {
Expand Down Expand Up @@ -261,7 +267,7 @@ function drawFigure(data, figure, context) {
const cs = figure.colors;
let i, ii;
switch (figure.type) {
case "lattice":
case MeshFigureType.LATTICE:
const verticesPerRow = figure.verticesPerRow;
const rows = Math.floor(ps.length / verticesPerRow) - 1;
const cols = verticesPerRow - 1;
Expand Down Expand Up @@ -291,7 +297,7 @@ function drawFigure(data, figure, context) {
}
}
break;
case "triangles":
case MeshFigureType.TRIANGLES:
for (i = 0, ii = ps.length; i < ii; i += 3) {
drawTriangle(
data,
Expand Down
7 changes: 7 additions & 0 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ const PermissionFlag = {
PRINT_HIGH_QUALITY: 0x800,
};

const MeshFigureType = {
TRIANGLES: 1,
LATTICE: 2,
PATCH: 3,
};

const TextRenderingMode = {
FILL: 0,
STROKE: 1,
Expand Down Expand Up @@ -1327,6 +1333,7 @@ export {
LINE_DESCENT_FACTOR,
LINE_FACTOR,
MathClamp,
MeshFigureType,
normalizeUnicode,
objectSize,
OPS,
Expand Down