Cleanup
This commit is contained in:
parent
f0196ec1e4
commit
6a307b5973
3 changed files with 25 additions and 26 deletions
|
@ -145,7 +145,6 @@ class QuadifySink {
|
||||||
let c = this.lastContour;
|
let c = this.lastContour;
|
||||||
c = this.alignHVKnots(c);
|
c = this.alignHVKnots(c);
|
||||||
c = this.cleanupOccurrentKnots1(c);
|
c = this.cleanupOccurrentKnots1(c);
|
||||||
c = this.cleanupOccurrentKnots2(c);
|
|
||||||
c = this.removeColinearKnots(c);
|
c = this.removeColinearKnots(c);
|
||||||
this.contours.push(c);
|
this.contours.push(c);
|
||||||
}
|
}
|
||||||
|
@ -189,28 +188,27 @@ class QuadifySink {
|
||||||
alignY.apply();
|
alignY.apply();
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Occurrent cleanup -- corner-corner
|
||||||
cleanupOccurrentKnots1(c0) {
|
cleanupOccurrentKnots1(c0) {
|
||||||
const c = [c0[0]];
|
let drops = [];
|
||||||
for (let i = 1; i < c0.length; i++) {
|
for (let i = 0; i < c0.length; i++) drops[i] = false;
|
||||||
|
for (let i = 0; i < c0.length; i++) {
|
||||||
|
const iPost = (i + 1) % c0.length;
|
||||||
|
const pre = c0[i],
|
||||||
|
post = c0[iPost];
|
||||||
if (
|
if (
|
||||||
!(
|
pre.type === Point.Type.Corner &&
|
||||||
c0[i].type === Point.Type.Corner &&
|
post.type === Point.Type.Corner &&
|
||||||
c0[i - 1].type === Point.Type.Corner &&
|
isOccurrent(pre, post)
|
||||||
isOccurrent(c0[i], c0[i - 1])
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
c.push(c0[i]);
|
drops[iPost] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return c;
|
|
||||||
}
|
return dropBy(c0, drops);
|
||||||
cleanupOccurrentKnots2(c0) {
|
|
||||||
const c = c0.slice(0);
|
|
||||||
const zFirst = c[0],
|
|
||||||
zLast = c[c.length - 1];
|
|
||||||
if (isOccurrent(zFirst, zLast)) c.pop();
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeColinearKnots(c0) {
|
removeColinearKnots(c0) {
|
||||||
const c = c0.slice(0);
|
const c = c0.slice(0);
|
||||||
let lengthBefore = c.length,
|
let lengthBefore = c.length,
|
||||||
|
@ -288,12 +286,7 @@ const GetY = z => z.y;
|
||||||
const SetY = (z, y) => (z.y = y);
|
const SetY = (z, y) => (z.y = y);
|
||||||
|
|
||||||
function isOccurrent(zFirst, zLast) {
|
function isOccurrent(zFirst, zLast) {
|
||||||
return (
|
return zFirst.x === zLast.x && zFirst.y === zLast.y;
|
||||||
zFirst.type === Point.Type.Corner &&
|
|
||||||
zLast.type === Point.Type.Corner &&
|
|
||||||
zFirst.x === zLast.x &&
|
|
||||||
zFirst.y === zLast.y
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
function occurrentPrecisionEqual(a, b) {
|
function occurrentPrecisionEqual(a, b) {
|
||||||
return Math.abs(a - b) < CurveUtil.OCCURRENT_PRECISION;
|
return Math.abs(a - b) < CurveUtil.OCCURRENT_PRECISION;
|
||||||
|
@ -304,3 +297,10 @@ function aligned(a, b, c) {
|
||||||
function between(a, b, c) {
|
function between(a, b, c) {
|
||||||
return (a <= b && b <= c) || (a >= b && b >= c);
|
return (a <= b && b <= c) || (a >= b && b >= c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dropping helper
|
||||||
|
function dropBy(a, d) {
|
||||||
|
let r = [];
|
||||||
|
for (let i = 0; i < a.length; i++) if (!d[i]) r.push(a[i]);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
|
@ -131,8 +131,7 @@ glyph-block Letter-Latin-Ezh : begin
|
||||||
local y : mix [mix b XH 0.6] b 0.5
|
local y : mix [mix b XH 0.6] b 0.5
|
||||||
include : dispiro
|
include : dispiro
|
||||||
widths.rhs
|
widths.rhs
|
||||||
g4 (RightSB - OX) y [heading Downward]
|
g4.down.mid (RightSB - OX) y [heading Downward]
|
||||||
g4 (RightSB - OX) (y - 1) [heading Downward]
|
|
||||||
arcvh
|
arcvh
|
||||||
flat [mix SB RightSB 0.45] b
|
flat [mix SB RightSB 0.45] b
|
||||||
curl [mix SB RightSB 0.4] b
|
curl [mix SB RightSB 0.4] b
|
||||||
|
@ -153,7 +152,7 @@ glyph-block Letter-Latin-Ezh : begin
|
||||||
local y2 Descender
|
local y2 Descender
|
||||||
include : dispiro
|
include : dispiro
|
||||||
widths.lhs
|
widths.lhs
|
||||||
g4.down.start m1 [mix [mix Descender XH 0.6] Descender p] [heading Downward]
|
g4.down.mid m1 [mix [mix Descender XH 0.6] Descender p] [heading Downward]
|
||||||
CurlyTail fine rinner m1 Descender SB x2 y2
|
CurlyTail fine rinner m1 Descender SB x2 y2
|
||||||
|
|
||||||
define [RetroflexConnectionTerminal top bot yMidBar] : begin
|
define [RetroflexConnectionTerminal top bot yMidBar] : begin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue