Unify the precision management of geometries
This commit is contained in:
parent
15c7381673
commit
84a8cb809c
6 changed files with 45 additions and 39 deletions
|
@ -2,9 +2,12 @@
|
|||
|
||||
const TypoGeom = require("typo-geom");
|
||||
const Point = require("./point");
|
||||
const { mix } = require("./utils");
|
||||
const Transform = require("./transform");
|
||||
|
||||
exports.GEOMETRY_PRECISION = 1 / 4;
|
||||
exports.RECIP_GEOMETRY_PRECISION = 4;
|
||||
exports.BOOLE_RESOLUTION = 0x4000;
|
||||
|
||||
exports.OffsetCurve = class OffsetCurve {
|
||||
constructor(bone, offset, contrast) {
|
||||
this.bone = bone;
|
||||
|
@ -31,7 +34,7 @@ exports.OffsetCurve = class OffsetCurve {
|
|||
}
|
||||
};
|
||||
|
||||
function convertContourToCubic(contour) {
|
||||
exports.convertContourToCubic = function convertContourToCubic(contour) {
|
||||
if (!contour || !contour.length) return [];
|
||||
|
||||
const newContour = [];
|
||||
|
@ -70,7 +73,11 @@ function convertContourToCubic(contour) {
|
|||
}
|
||||
|
||||
return newContour;
|
||||
}
|
||||
};
|
||||
|
||||
exports.convertShapeToArcs = function convertShapeToArcs(shape) {
|
||||
return shape.map(convertContourToArcs);
|
||||
};
|
||||
|
||||
function convertContourToArcs(contour) {
|
||||
if (!contour || !contour.length) return [];
|
||||
|
@ -124,13 +131,6 @@ function convertContourToArcs(contour) {
|
|||
return newContour;
|
||||
}
|
||||
|
||||
function convertShapeToArcs(shape) {
|
||||
return shape.map(convertContourToArcs);
|
||||
}
|
||||
|
||||
exports.convertContourToCubic = convertContourToCubic;
|
||||
exports.convertShapeToArcs = convertShapeToArcs;
|
||||
|
||||
exports.BezToContoursSink = class BezToContoursSink {
|
||||
constructor(gizmo) {
|
||||
this.gizmo = gizmo || Transform.Id();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue