pts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +283 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +283 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6018 -4596
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6017 -4597
- package/dist/index.mjs.map +1 -1
- package/dist/pts.js +4362 -2940
- package/dist/pts.js.map +1 -1
- package/dist/pts.min.js +2 -2
- package/dist/pts.min.js.map +1 -1
- package/package.json +3 -2
- package/src/Canvas.ts +99 -4
- package/src/Create.ts +288 -1
- package/src/Dom.ts +1 -1
- package/src/Num.ts +3 -1
- package/src/Op.ts +315 -0
- package/src/Pt.ts +8 -1
- package/src/Svg.ts +79 -0
- package/src/Types.ts +17 -0
- package/src/_path.ts +1402 -0
- package/src/_triangulate.ts +41 -0
package/src/_triangulate.ts
CHANGED
|
@@ -359,6 +359,47 @@ function _scaled(values: Float64Array, count: number): bigint[] {
|
|
|
359
359
|
return out;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
// `Number(bigint)` is finite below 2^1024; shift in whole limbs until then.
|
|
363
|
+
const FINITE_LIMIT = BigInt(1) << BigInt(1023);
|
|
364
|
+
const SHIFT_STEP = BigInt(64);
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Parameter of a known proper crossing along a→b. Evaluate the determinants
|
|
368
|
+
* exactly before division: shallow crossings can lose most of their digits
|
|
369
|
+
* when two rounded products are subtracted. Used by the polygon overlay.
|
|
370
|
+
*/
|
|
371
|
+
export function crossingParameter(
|
|
372
|
+
ax: number,
|
|
373
|
+
ay: number,
|
|
374
|
+
bx: number,
|
|
375
|
+
by: number,
|
|
376
|
+
cx: number,
|
|
377
|
+
cy: number,
|
|
378
|
+
dx: number,
|
|
379
|
+
dy: number,
|
|
380
|
+
): number {
|
|
381
|
+
_input.set([ax, ay, bx, by, cx, cy, dx, dy]);
|
|
382
|
+
const [a, b, c, d, e, f, g, h] = _scaled(_input, 8);
|
|
383
|
+
const rx = g - e;
|
|
384
|
+
const ry = h - f;
|
|
385
|
+
let numerator = rx * (b - f) - ry * (a - e);
|
|
386
|
+
let denominator = numerator - (rx * (d - f) - ry * (c - e));
|
|
387
|
+
if (denominator < BigInt(0)) {
|
|
388
|
+
numerator = -numerator;
|
|
389
|
+
denominator = -denominator;
|
|
390
|
+
}
|
|
391
|
+
// Keep the conversion finite even when the input doubles span hundreds of
|
|
392
|
+
// binary exponents. The numerator is between zero and the denominator, and
|
|
393
|
+
// a denominator of ordinary size needs no shift at all.
|
|
394
|
+
let shift = BigInt(0);
|
|
395
|
+
let scaled = denominator;
|
|
396
|
+
while (scaled >= FINITE_LIMIT) {
|
|
397
|
+
scaled >>= SHIFT_STEP;
|
|
398
|
+
shift += SHIFT_STEP;
|
|
399
|
+
}
|
|
400
|
+
return Number(numerator >> shift) / Number(scaled);
|
|
401
|
+
}
|
|
402
|
+
|
|
362
403
|
/** Exact orientation, evaluated in BigInt. Used when the fast filter cannot decide. */
|
|
363
404
|
export function orient2dExact(
|
|
364
405
|
ax: number,
|