Format cleanup

This commit is contained in:
be5invis 2022-07-17 00:31:02 -07:00
parent 36835216f5
commit e61edd0db9
13 changed files with 52 additions and 52 deletions

View file

@ -109,12 +109,12 @@ export class ReverseCurve {
export function convertShapeToArcs(shape) {
return shape.map(convertContourToArcs);
}
export const shapeToRep = function (shape) {
export function shapeToRep(shape) {
return shape.map(contourToRep);
};
export const repToShape = function (shapeRep) {
}
export function repToShape(shapeRep) {
return shapeRep.map(repToContour);
};
}
export class BezToContoursSink {
constructor(gizmo) {
this.gizmo = gizmo || Transform.Id();

View file

@ -10,7 +10,7 @@ import { Point } from "./point.mjs";
import { SpiroExpander } from "./spiro-expand.mjs";
import { Transform } from "./transform.mjs";
class GeometryBase {
export class GeometryBase {
asContours() {
throw new Error("Unimplemented");
}
@ -33,7 +33,8 @@ class GeometryBase {
return null;
}
}
class ContourGeometry extends GeometryBase {
export class ContourGeometry extends GeometryBase {
constructor(points) {
super();
this.m_points = [];
@ -66,7 +67,8 @@ class ContourGeometry extends GeometryBase {
return Format.struct(`ContourGeometry`, Format.list(this.m_points.map(Format.typedPoint)));
}
}
class SpiroGeometry extends GeometryBase {
export class SpiroGeometry extends GeometryBase {
constructor(gizmo, closed, knots) {
super();
this.m_knots = [];
@ -108,7 +110,8 @@ class SpiroGeometry extends GeometryBase {
);
}
}
class DiSpiroGeometry extends GeometryBase {
export class DiSpiroGeometry extends GeometryBase {
constructor(gizmo, contrast, closed, biKnots) {
super();
this.m_biKnots = [];
@ -178,7 +181,8 @@ class DiSpiroGeometry extends GeometryBase {
);
}
}
class ReferenceGeometry extends GeometryBase {
export class ReferenceGeometry extends GeometryBase {
constructor(glyph, x, y) {
super();
if (!glyph || !glyph.geometry) throw new TypeError("Invalid glyph");
@ -220,7 +224,8 @@ class ReferenceGeometry extends GeometryBase {
return Format.struct("ReferenceGeometry", sTarget, Format.n(this.m_x), Format.n(this.m_y));
}
}
class TaggedGeometry extends GeometryBase {
export class TaggedGeometry extends GeometryBase {
constructor(g, tag) {
super();
this.m_geom = g;
@ -249,7 +254,8 @@ class TaggedGeometry extends GeometryBase {
return this.m_geom.toShapeStringOrNull();
}
}
class TransformedGeometry extends GeometryBase {
export class TransformedGeometry extends GeometryBase {
constructor(g, tfm) {
super();
this.m_geom = g;
@ -310,7 +316,8 @@ class TransformedGeometry extends GeometryBase {
return Format.struct("TransformedGeometry", sTarget, Format.gizmo(this.m_transform));
}
}
class CombineGeometry extends GeometryBase {
export class CombineGeometry extends GeometryBase {
constructor(parts) {
super();
this.m_parts = parts || [];
@ -380,7 +387,8 @@ class CombineGeometry extends GeometryBase {
return Format.struct("CombineGeometry", Format.list(sParts));
}
}
class BooleanGeometry extends GeometryBase {
export class BooleanGeometry extends GeometryBase {
constructor(operator, operands) {
super();
this.m_operator = operator;
@ -454,25 +462,17 @@ class BooleanGeometry extends GeometryBase {
return Format.struct("BooleanGeometry", this.m_operator, Format.list(sParts));
}
}
function combineWith(a, b) {
export function combineWith(a, b) {
if (a instanceof CombineGeometry) {
return a.with(b);
} else {
return new CombineGeometry([a, b]);
}
}
export const hashGeometry = function (geom) {
export function hashGeometry(geom) {
const s = geom.toShapeStringOrNull();
if (!s) return null;
return crypto.createHash("sha256").update(s).digest("hex");
};
export { GeometryBase };
export { SpiroGeometry };
export { DiSpiroGeometry };
export { ContourGeometry };
export { ReferenceGeometry };
export { TaggedGeometry };
export { TransformedGeometry };
export { CombineGeometry };
export { BooleanGeometry };
export { combineWith };
}

View file

@ -8,7 +8,7 @@ function createBuildup(simple, buildup) {
}
return Array.from(ligSet);
}
export const applyLigationData = function (data, para, argv) {
export function applyLigationData(data, para, argv) {
const defaultBuildup = {};
const hives = {};
hives["default"] = { caltBuildup: [] };
@ -43,4 +43,4 @@ export const applyLigationData = function (data, para, argv) {
argv.ligations.enables.map(x => `ligset-enable-${x}`)
);
}
};
}

View file

@ -5,6 +5,6 @@ export function maskBit(x, y) {
export function maskBits(x, y) {
return x & y;
}
export const popCountByte = function (x) {
export function popCountByte(x) {
return pcNibbleLookup[x & 0x0f] + pcNibbleLookup[(x >>> 4) & 0x0f];
};
}

View file

@ -1,4 +1,4 @@
export const monotonicInterpolate = function (xs, ys) {
export function monotonicInterpolate(xs, ys) {
let i,
length = xs.length;
// Deal with length issues
@ -101,4 +101,4 @@ export const monotonicInterpolate = function (xs, ys) {
diffSq = diff * diff;
return ys[i] + c1s[i] * diff + c2s[i] * diffSq + c3s[i] * diff * diffSq;
};
};
}