format and fix certain build breaks
This commit is contained in:
parent
12a3b8c244
commit
d5661093ff
65 changed files with 553 additions and 862 deletions
|
@ -1,8 +1,8 @@
|
|||
import { mix } from "@iosevka/util";
|
||||
import * as TypoGeom from "typo-geom";
|
||||
|
||||
import { Point, Vec2 } from "./point.mjs";
|
||||
import { Transform } from "./transform.mjs";
|
||||
import { mix } from "@iosevka/util";
|
||||
|
||||
function contourToRep(contour) {
|
||||
let c = [];
|
||||
|
@ -30,8 +30,8 @@ function convertContourToArcs(contour) {
|
|||
z0,
|
||||
Point.from(Point.Type.CubicStart, z1),
|
||||
Point.from(Point.Type.CubicEnd, z2),
|
||||
Point.from(Point.Type.Corner, z3)
|
||||
)
|
||||
Point.from(Point.Type.Corner, z3),
|
||||
),
|
||||
);
|
||||
z0 = z3;
|
||||
j += 2;
|
||||
|
@ -47,8 +47,8 @@ function convertContourToArcs(contour) {
|
|||
z0,
|
||||
Point.from(Point.Type.CubicStart, z0).mix(2 / 3, zc),
|
||||
Point.from(Point.Type.CubicEnd, zf).mix(2 / 3, zc),
|
||||
Point.from(Point.Type.Corner, zf)
|
||||
)
|
||||
Point.from(Point.Type.Corner, zf),
|
||||
),
|
||||
);
|
||||
z0 = zf;
|
||||
if (zfIsCorner) j++;
|
||||
|
@ -57,8 +57,8 @@ function convertContourToArcs(contour) {
|
|||
default: {
|
||||
newContour.push(
|
||||
TypoGeom.Arcs.Bez3.fromStraightSegment(
|
||||
new TypoGeom.Arcs.StraightSegment(z0, Point.from(Point.Type.Corner, z))
|
||||
)
|
||||
new TypoGeom.Arcs.StraightSegment(z0, Point.from(Point.Type.Corner, z)),
|
||||
),
|
||||
);
|
||||
z0 = z;
|
||||
break;
|
||||
|
@ -88,7 +88,7 @@ export function derivativeFromFiniteDifference(c, t) {
|
|||
(2 / 3) * backward1.y +
|
||||
(2 / 3) * forward1.y -
|
||||
(1 / 12) * forward2.y) /
|
||||
DELTA
|
||||
DELTA,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ export class OffsetCurve {
|
|||
const absD = Math.hypot(d.x, d.y);
|
||||
return {
|
||||
x: c.x - (d.y / absD) * this.offset * this.contrast,
|
||||
y: c.y + (d.x / absD) * this.offset
|
||||
y: c.y + (d.x / absD) * this.offset,
|
||||
};
|
||||
}
|
||||
derivative(t) {
|
||||
|
@ -189,7 +189,7 @@ export class RoundCapCurve {
|
|||
|
||||
return {
|
||||
x: centerX + r * Math.cos(theta) * this.contrast,
|
||||
y: centerY + r * Math.sin(theta)
|
||||
y: centerY + r * Math.sin(theta),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ export class ContourSetGeometry extends GeometryBase {
|
|||
toShapeStringOrNull() {
|
||||
return Format.struct(
|
||||
`ContourSetGeometry`,
|
||||
Format.list(this.m_contours.map(c => Format.list(c.map(Format.typedPoint))))
|
||||
Format.list(this.m_contours.map(c => Format.list(c.map(Format.typedPoint)))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ export class SpiroGeometry extends GeometryBase {
|
|||
"SpiroGeometry",
|
||||
Format.gizmo(this.m_gizmo),
|
||||
this.m_closed,
|
||||
Format.list(this.m_knots.map(k => k.toShapeString()))
|
||||
Format.list(this.m_knots.map(k => k.toShapeString())),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ export class DiSpiroGeometry extends GeometryBase {
|
|||
if (this.m_closed) {
|
||||
outlineGeometry = new CombineGeometry([
|
||||
new SpiroGeometry(this.m_gizmo, true, lhs),
|
||||
new SpiroGeometry(this.m_gizmo, true, rhs)
|
||||
new SpiroGeometry(this.m_gizmo, true, rhs),
|
||||
]);
|
||||
} else {
|
||||
lhs[0].type = lhs[lhs.length - 1].type = "corner";
|
||||
|
@ -155,7 +155,7 @@ export class DiSpiroGeometry extends GeometryBase {
|
|||
this.m_gizmo,
|
||||
this.m_contrast,
|
||||
this.m_closed,
|
||||
this.m_biKnots
|
||||
this.m_biKnots,
|
||||
);
|
||||
expander.initializeNormals();
|
||||
expander.iterateNormals();
|
||||
|
@ -187,7 +187,7 @@ export class DiSpiroGeometry extends GeometryBase {
|
|||
Format.gizmo(this.m_gizmo),
|
||||
Format.n(this.m_contrast),
|
||||
this.m_closed,
|
||||
Format.list(this.m_biKnots.map(z => z.toShapeString()))
|
||||
Format.list(this.m_biKnots.map(z => z.toShapeString())),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ export class ReferenceGeometry extends GeometryBase {
|
|||
unwrap() {
|
||||
return new TransformedGeometry(
|
||||
this.m_glyph.geometry,
|
||||
Transform.Translate(this.m_x, this.m_y)
|
||||
Transform.Translate(this.m_x, this.m_y),
|
||||
);
|
||||
}
|
||||
toContours() {
|
||||
|
@ -317,8 +317,8 @@ export class TransformedGeometry extends GeometryBase {
|
|||
unwrapped.m_geom,
|
||||
Transform.Translate(
|
||||
this.m_transform.tx + unwrapped.m_transform.tx,
|
||||
this.m_transform.ty + unwrapped.m_transform.ty
|
||||
)
|
||||
this.m_transform.ty + unwrapped.m_transform.ty,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return new TransformedGeometry(unwrapped, this.m_transform);
|
||||
|
@ -467,7 +467,7 @@ export class BooleanGeometry extends GeometryBase {
|
|||
sink.push({
|
||||
type: "operand",
|
||||
fillType: TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
shape: []
|
||||
shape: [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ export class BooleanGeometry extends GeometryBase {
|
|||
sink.push({
|
||||
type: "operand",
|
||||
fillType: TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
shape: CurveUtil.convertShapeToArcs(operand.toContours())
|
||||
shape: CurveUtil.convertShapeToArcs(operand.toContours()),
|
||||
});
|
||||
}
|
||||
// Push operator if i > 0
|
||||
|
@ -548,7 +548,7 @@ export class StrokeGeometry extends GeometryBase {
|
|||
let arcs = TypoGeom.Boolean.removeOverlap(
|
||||
CurveUtil.convertShapeToArcs(nonTransformedGeometry.toContours()),
|
||||
TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
CurveUtil.BOOLE_RESOLUTION
|
||||
CurveUtil.BOOLE_RESOLUTION,
|
||||
);
|
||||
|
||||
// Fairize to get get some arcs that are simple enough
|
||||
|
@ -559,7 +559,7 @@ export class StrokeGeometry extends GeometryBase {
|
|||
fairizedArcs,
|
||||
this.m_radius,
|
||||
this.m_contrast,
|
||||
this.m_fInside
|
||||
this.m_fInside,
|
||||
);
|
||||
|
||||
// Convert to Iosevka format
|
||||
|
@ -580,7 +580,7 @@ export class StrokeGeometry extends GeometryBase {
|
|||
this.m_gizmo,
|
||||
this.m_radius,
|
||||
this.m_contrast,
|
||||
this.m_fInside
|
||||
this.m_fInside,
|
||||
);
|
||||
}
|
||||
filterTag(fn) {
|
||||
|
@ -589,7 +589,7 @@ export class StrokeGeometry extends GeometryBase {
|
|||
this.m_gizmo,
|
||||
this.m_radius,
|
||||
this.m_contrast,
|
||||
this.m_fInside
|
||||
this.m_fInside,
|
||||
);
|
||||
}
|
||||
measureComplexity() {
|
||||
|
@ -604,7 +604,7 @@ export class StrokeGeometry extends GeometryBase {
|
|||
Format.gizmo(this.m_gizmo),
|
||||
Format.n(this.m_radius),
|
||||
Format.n(this.m_contrast),
|
||||
this.m_fInside
|
||||
this.m_fInside,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ export class SimplifyGeometry extends GeometryBase {
|
|||
arcs = TypoGeom.Boolean.removeOverlap(
|
||||
arcs,
|
||||
TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
CurveUtil.BOOLE_RESOLUTION
|
||||
CurveUtil.BOOLE_RESOLUTION,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ export class SimplifyGeometry extends GeometryBase {
|
|||
TypoGeom.ShapeConv.transferGenericShape(
|
||||
TypoGeom.Fairize.fairizeBezierShape(arcs),
|
||||
sink,
|
||||
CurveUtil.GEOMETRY_PRECISION
|
||||
CurveUtil.GEOMETRY_PRECISION,
|
||||
);
|
||||
return sink.contours;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ export class Point {
|
|||
return new Point(
|
||||
this.type,
|
||||
this.x + scale * (z2.x - this.x),
|
||||
this.y + scale * (z2.y - this.y)
|
||||
this.y + scale * (z2.y - this.y),
|
||||
);
|
||||
}
|
||||
scale(t) {
|
||||
|
@ -74,5 +74,5 @@ Point.Type = {
|
|||
Corner: 0,
|
||||
CubicStart: 1,
|
||||
CubicEnd: 2,
|
||||
Quadratic: 3
|
||||
Quadratic: 3,
|
||||
};
|
||||
|
|
|
@ -168,7 +168,7 @@ class BiKnot {
|
|||
this.d2 == null ? "" : Format.n(this.d2),
|
||||
this.proposedNormal
|
||||
? Format.tuple(Format.n(this.proposedNormal.x), Format.n(this.proposedNormal.y))
|
||||
: ""
|
||||
: "",
|
||||
);
|
||||
}
|
||||
toMono() {
|
||||
|
|
|
@ -34,7 +34,7 @@ export class SpiroExpander {
|
|||
this.m_biKnotsT[j].type,
|
||||
this.m_biKnotsT[j].unimportant,
|
||||
mix(lhs.x, rhs.x, 0.5),
|
||||
mix(lhs.y, rhs.y, 0.5)
|
||||
mix(lhs.y, rhs.y, 0.5),
|
||||
);
|
||||
}
|
||||
return middles;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as SpiroJs from "spiro";
|
||||
|
||||
import * as CurveUtil from "./curve-util.mjs";
|
||||
|
||||
export function spiroToOutline(knots, fClosed, gizmo) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import * as TypoGeom from "typo-geom";
|
||||
|
||||
import {
|
||||
BOOLE_RESOLUTION,
|
||||
Bez3FromHermite,
|
||||
GEOMETRY_PRECISION,
|
||||
OCCURRENT_PRECISION,
|
||||
OffsetCurve,
|
||||
RoundCapCurve
|
||||
RoundCapCurve,
|
||||
} from "./curve-util.mjs";
|
||||
|
||||
export function strokeArcs(arcs, radius, contrast, fInside) {
|
||||
|
@ -24,7 +24,7 @@ export function strokeArcs(arcs, radius, contrast, fInside) {
|
|||
bezs,
|
||||
TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
BOOLE_RESOLUTION
|
||||
BOOLE_RESOLUTION,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ export function strokeArcs(arcs, radius, contrast, fInside) {
|
|||
currentArcs,
|
||||
TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
TypoGeom.Boolean.PolyFillType.pftNonZero,
|
||||
BOOLE_RESOLUTION
|
||||
BOOLE_RESOLUTION,
|
||||
);
|
||||
} else {
|
||||
return currentArcs;
|
||||
|
@ -72,8 +72,8 @@ function offsetContour(arcs, distance, contrast) {
|
|||
prevOffsetedArc.derivative(1),
|
||||
currentOffsetedArc.bone.eval(0),
|
||||
currentStart,
|
||||
currentOffsetedArc.derivative(0)
|
||||
)
|
||||
currentOffsetedArc.derivative(0),
|
||||
),
|
||||
);
|
||||
// offsetArcs.push(Bez3FromHermite(prevEnd, dPrevEnd, currentStart, dCurrentStart));
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ function createCap(
|
|||
dPrevEnd, // Previous offseted curve's end point's derivative
|
||||
currentStartNoOffset, // Current non-offseted curve's start point
|
||||
currentStart, // Current offseted curve's start point
|
||||
dCurrentStart // Current offseted curve's start point's derivative
|
||||
dCurrentStart, // Current offseted curve's start point's derivative
|
||||
) {
|
||||
return new RoundCapCurve(
|
||||
side,
|
||||
|
@ -109,6 +109,6 @@ function createCap(
|
|||
prevEndNoOffset,
|
||||
prevEnd,
|
||||
currentStartNoOffset,
|
||||
currentStart
|
||||
currentStart,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ export class Transform {
|
|||
applyOffsetXY(deltaX, deltaY) {
|
||||
return {
|
||||
x: deltaX * this.xx + deltaY * this.xy,
|
||||
y: deltaX * this.yx + deltaY * this.yy
|
||||
y: deltaX * this.yx + deltaY * this.yy,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ export class Transform {
|
|||
-this.yx / denom,
|
||||
this.xx / denom,
|
||||
-(this.tx * this.yy - this.ty * this.xy) / denom,
|
||||
-(-this.tx * this.yx + this.ty * this.xx) / denom
|
||||
-(-this.tx * this.yx + this.ty * this.xx) / denom,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ export class Transform {
|
|||
z10.y - z00.y,
|
||||
z01.y - z00.y,
|
||||
z00.x,
|
||||
z00.y
|
||||
z00.y,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue