bump deps and more cleanup
This commit is contained in:
parent
f72b039ec4
commit
6e79c9e5c7
53 changed files with 440 additions and 638 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@iosevka/geometry",
|
||||
"version": "29.0.0-beta.1",
|
||||
"version": "29.0.0-beta.2",
|
||||
"private": true,
|
||||
"exports": {
|
||||
".": "./src/index.mjs",
|
||||
|
@ -13,8 +13,8 @@
|
|||
"./spiro-control": "./src/spiro-control.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iosevka/util": "29.0.0-beta.1",
|
||||
"@iosevka/util": "29.0.0-beta.2",
|
||||
"spiro": "^3.0.0",
|
||||
"typo-geom": "^0.14.0"
|
||||
"typo-geom": "^0.15.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ export class Anchor {
|
|||
return Anchor.transform(tfm, this);
|
||||
}
|
||||
static transform(tfm, a) {
|
||||
const x = a.x * tfm.xx + a.y * tfm.yx + tfm.x;
|
||||
const y = a.x * tfm.xy + a.y * tfm.yy + tfm.y;
|
||||
return new Anchor(x, y);
|
||||
return new Anchor(tfm.applyX(a.x, a.y), tfm.applyY(a.x, a.y));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ export class TransformedGeometry extends GeometryBase {
|
|||
if (!rs) return null;
|
||||
let result = [];
|
||||
for (const { glyph, x, y } of rs)
|
||||
result.push({ glyph, x: x + this.m_transform.x, y: y + this.m_transform.y });
|
||||
result.push({ glyph, x: x + this.m_transform.tx, y: y + this.m_transform.ty });
|
||||
return result;
|
||||
}
|
||||
getDependencies() {
|
||||
|
@ -316,8 +316,8 @@ export class TransformedGeometry extends GeometryBase {
|
|||
return new TransformedGeometry(
|
||||
unwrapped.m_geom,
|
||||
Transform.Translate(
|
||||
this.m_transform.x + unwrapped.m_transform.x,
|
||||
this.m_transform.y + unwrapped.m_transform.y
|
||||
this.m_transform.tx + unwrapped.m_transform.tx,
|
||||
this.m_transform.ty + unwrapped.m_transform.ty
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -61,11 +61,7 @@ export class Point {
|
|||
return Point.transformedXY(tfm, z.type, z.x, z.y);
|
||||
}
|
||||
static transformedXY(tfm, type, x, y) {
|
||||
return new Point(
|
||||
type,
|
||||
x * tfm.xx + y * tfm.yx + tfm.x || 0,
|
||||
x * tfm.xy + y * tfm.yy + tfm.y || 0
|
||||
);
|
||||
return new Point(type, tfm.applyX(x, y), tfm.applyY(x, y));
|
||||
}
|
||||
static translated(z, dx, dy) {
|
||||
return new Point(z.type, z.x + dx || 0, z.y + dy || 0);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { Vec2 } from "./point.mjs";
|
||||
|
||||
export class Transform {
|
||||
constructor(xx, yx, xy, yy, x, y) {
|
||||
constructor(xx, xy, yx, yy, tx, ty) {
|
||||
this.xx = xx;
|
||||
this.yx = yx;
|
||||
this.xy = xy;
|
||||
this.yx = yx;
|
||||
this.yy = yy;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.tx = tx;
|
||||
this.ty = ty;
|
||||
}
|
||||
static Id() {
|
||||
return new Transform(1, 0, 0, 1, 0, 0);
|
||||
|
@ -17,10 +17,10 @@ export class Transform {
|
|||
}
|
||||
|
||||
applyX(x, y) {
|
||||
return x * this.xx + y * this.yx + this.x;
|
||||
return x * this.xx + y * this.xy + this.tx;
|
||||
}
|
||||
applyY(x, y) {
|
||||
return x * this.xy + y * this.yy + this.y;
|
||||
return x * this.yx + y * this.yy + this.ty;
|
||||
}
|
||||
applyXY(x, y) {
|
||||
return new Vec2(this.applyX(x, y), this.applyY(x, y));
|
||||
|
@ -38,17 +38,17 @@ export class Transform {
|
|||
}
|
||||
applyOffsetXY(deltaX, deltaY) {
|
||||
return {
|
||||
x: deltaX * this.xx + deltaY * this.yx,
|
||||
y: deltaX * this.xy + deltaY * this.yy
|
||||
x: deltaX * this.xx + deltaY * this.xy,
|
||||
y: deltaX * this.yx + deltaY * this.yy
|
||||
};
|
||||
}
|
||||
|
||||
unapplyToSink(pt, sink) {
|
||||
const xx = pt.x - this.x;
|
||||
const yy = pt.y - this.y;
|
||||
const denom = this.xx * this.yy - this.xy * this.yx;
|
||||
sink.x = (xx * this.yy - yy * this.yx) / denom;
|
||||
sink.y = (yy * this.xx - xx * this.xy) / denom;
|
||||
const xx = pt.x - this.tx;
|
||||
const yy = pt.y - this.ty;
|
||||
const denom = this.xx * this.yy - this.yx * this.xy;
|
||||
sink.x = (xx * this.yy - yy * this.xy) / denom;
|
||||
sink.y = (yy * this.xx - xx * this.yx) / denom;
|
||||
}
|
||||
unapply(pt) {
|
||||
let sink = new Vec2(0, 0);
|
||||
|
@ -60,25 +60,25 @@ export class Transform {
|
|||
else return null;
|
||||
}
|
||||
inverse() {
|
||||
const denom = this.xx * this.yy - this.xy * this.yx;
|
||||
const denom = this.xx * this.yy - this.yx * this.xy;
|
||||
return new Transform(
|
||||
this.yy / denom,
|
||||
-this.yx / denom,
|
||||
-this.xy / denom,
|
||||
-this.yx / denom,
|
||||
this.xx / denom,
|
||||
-(this.x * this.yy - this.y * this.yx) / denom,
|
||||
-(-this.x * this.xy + this.y * this.xx) / denom
|
||||
-(this.tx * this.yy - this.ty * this.xy) / denom,
|
||||
-(-this.tx * this.yx + this.ty * this.xx) / denom
|
||||
);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `[[${this.xx} ${this.xy}] [${this.yx} ${this.yy}]] + [[${this.x}] [${this.y}]]`;
|
||||
return `[[${this.xx} ${this.yx}] [${this.xy} ${this.yy}]] + [[${this.tx}] [${this.ty}]]`;
|
||||
}
|
||||
static isTranslate(tfm) {
|
||||
return tfm.xx === 1 && tfm.yy === 1 && tfm.xy === 0 && tfm.yx === 0;
|
||||
}
|
||||
static isIdentity(tfm) {
|
||||
return this.isTranslate(tfm) && tfm.x === 0 && tfm.y === 0;
|
||||
return this.isTranslate(tfm) && tfm.tx === 0 && tfm.ty === 0;
|
||||
}
|
||||
static isPositive(tfm) {
|
||||
return tfm.xx * tfm.yy - tfm.xy * tfm.yx > 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue