Cache the entire geometry flattener

This commit is contained in:
be5invis 2021-04-17 15:42:07 -07:00
parent edbe5ff47e
commit 4c8de9f025
4 changed files with 95 additions and 56 deletions

View file

@ -1,7 +1,5 @@
"use strict";
const crypto = require("crypto");
const TypoGeom = require("typo-geom");
const Point = require("./point");
const Transform = require("./transform");
@ -53,18 +51,6 @@ exports.convertShapeToArcs = function convertShapeToArcs(shape) {
return shape.map(convertContourToArcs);
};
exports.hashShape = function (shape) {
let s = "";
for (const c of shape) {
s += "[";
for (const z of c) {
s += `[${z.type};${Math.round(z.x * 0x10000)};${Math.round(z.y * 0x10000)}]`;
}
s += "]";
}
return crypto.createHash("sha256").update(s).digest();
};
function contourToRep(contour) {
let c = [];
for (const z of contour) c.push({ type: z.type, x: z.x, y: z.y });