@mark1russell7/layout-contract 0.9.4 → 0.9.5

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.
@@ -57,8 +57,8 @@ type Region = {
57
57
  readonly h: number;
58
58
  } | {
59
59
  readonly kind: "polygon";
60
- readonly points: readonly (readonly [number, number])[];
61
- readonly holes?: readonly (readonly (readonly [number, number])[])[];
60
+ readonly points: Ring;
61
+ readonly holes?: readonly Ring[];
62
62
  } | {
63
63
  readonly kind: "circle";
64
64
  readonly cx: number;
@@ -97,15 +97,28 @@ declare function overlapOf(a: Rect, b: Rect): {
97
97
  /**
98
98
  * This function tells if the segments `ab` and `cd` cross at one point inside both of them.
99
99
  * Segments that only touch at an end, or that are collinear, do not cross. The test has no tolerance.
100
+ * The signs are exact, so an input that is almost collinear gets the correct answer. A coordinate that is not finite gives `false`.
100
101
  */
101
102
  declare function segmentsCross(a: Point, b: Point, c: Point, d: Point): boolean;
102
103
  /**
103
104
  * This function gives the point where the segments `ab` and `cd` cross, or `undefined`.
104
105
  * It gives a point exactly when `segmentsCross` is true, so a touch at an end and collinear segments give `undefined`.
106
+ * The point comes from float cross products. For an input that is almost collinear, the point stays on `ab`.
105
107
  */
106
108
  declare function crossingPoint(a: Point, b: Point, c: Point, d: Point): Point | undefined;
107
109
  /** This function gives the shortest distance from `p` to the segment `ab`. A segment of length 0 is the point `a`. */
108
110
  declare function pointSegmentDistance(p: Point, a: Point, b: Point): number;
111
+ /** A ring of a polygon: its corners in order, as `[x, y]` pairs. The last corner connects to the first. */
112
+ type Ring = readonly (readonly [number, number])[];
113
+ /** This function tells if the point (`x`, `y`) is inside a ring, by the even-odd rule. A ring can be concave. The answer for a point on the border can be each value. */
114
+ declare function pointInRing(x: number, y: number, ring: Ring): boolean;
115
+ /**
116
+ * This function tells if the point (`x`, `y`) is inside a set of rings, by the even-odd rule over all their sides.
117
+ * Thus a point inside the outer ring and inside a hole is out. The answer for a point on a border can be each value.
118
+ */
119
+ declare function pointInRings(x: number, y: number, rings: readonly Ring[]): boolean;
120
+ /** This function gives the distance between the centers of two rectangles. */
121
+ declare function boxCenterDistance(a: Rect, b: Rect): number;
109
122
  /**
110
123
  * This function gives the index at which a point goes among the items of a list on the screen.
111
124
  * The reading order is the rows from top to bottom, and each row from left to right.
@@ -657,5 +670,5 @@ declare function minEffectOf(spec: Pick<MeasureSpec, "minEffect">, a?: number, b
657
670
  * Two equal values are a tie, also two infinite values. A value `NaN` is an error.
658
671
  */
659
672
  declare function compareMeasure(candidate: number, baseline: number, spec: Pick<MeasureSpec, "direction" | "minEffect">): Verdict;
660
- export { CorpusSplit as $, shapeKindsOf as A, overlapOf as At, LayoutInput as B, checkShapes as C, Sides as Ct, ruleLevel as D, dropIndex as Dt, itemShapeOf as E, crossingPoint as Et, LayoutBox as F, snapRect as Ft, PairGap as G, PackInput as H, LayoutCell as I, toRect as It, packLinks as J, Port as K, LayoutContainer as L, toSizedRect as Lt, shapeSupportProblems as M, regionArea as Mt, shapesOf as N, scaleRect as Nt, shapeKindOf as O, grow as Ot, Item as P, segmentsCross as Pt, CorpusEntry as Q, LayoutEdge as R, translate as Rt, boxArea as S, Side as St, isShapeKind as T, boundsOf as Tt, PackInputOptions as U, Obstacle as V, PackLink as W, toPackInput as X, portPoint as Y, ClaimBreak as Z, ShapeKind as _, Margin as _t, MeasureSpec as a, SPLIT_SCHEMA as at, ShapeLimit as b, Region as bt, minEffectOf as c, checkDeclared as ct, SHAPE_KINDS as d, declaredClaimOf as dt, DeclaredClaim as et, SHAPE_KIND_IDS as f, declaredCounts as ft, ShapeInput as g, splitFolds as gt, ShapeGeometry as h, splitFileName as ht, JointMeasureId as i, FamilyCell as it, shapeLevel as j, pointSegmentDistance as jt, shapeKindProblem as k, marginSides as kt, DEFAULT_SHAPES as l, checkSplit as lt, ShapeCheck as m, leaveOneSeedOut as mt, JOINT_MEASURES as n, FAMILY_ANY_KIND as nt, Verdict as o, SplitCorpus as ot, ShapeBound as p, familyOf as pt, canonicalInput as q, JOINT_MOVED_MIN as r, FamilyBy as rt, compareMeasure as s, SplitFold as st, Direction as t, Declares as tt, RuleLevel as u, corpusHashOf as ut, ShapeKindSpec as v, Point as vt, inputShapeLevel as w, SizedRect as wt, ShapeSupport as x, SIDES as xt, ShapeLevel as y, Rect as yt, LayoutGenerator as z };
661
- //# sourceMappingURL=measures-B_n_KDMd.d.ts.map
673
+ export { CorpusSplit as $, shapeKindsOf as A, grow as At, LayoutInput as B, toRect as Bt, checkShapes as C, Side as Ct, ruleLevel as D, boxCenterDistance as Dt, itemShapeOf as E, boundsOf as Et, LayoutBox as F, pointSegmentDistance as Ft, PairGap as G, PackInput as H, translate as Ht, LayoutCell as I, regionArea as It, packLinks as J, Port as K, LayoutContainer as L, scaleRect as Lt, shapeSupportProblems as M, overlapOf as Mt, shapesOf as N, pointInRing as Nt, shapeKindOf as O, crossingPoint as Ot, Item as P, pointInRings as Pt, CorpusEntry as Q, LayoutEdge as R, segmentsCross as Rt, boxArea as S, SIDES as St, isShapeKind as T, SizedRect as Tt, PackInputOptions as U, Obstacle as V, toSizedRect as Vt, PackLink as W, toPackInput as X, portPoint as Y, ClaimBreak as Z, ShapeKind as _, Margin as _t, MeasureSpec as a, SPLIT_SCHEMA as at, ShapeLimit as b, Region as bt, minEffectOf as c, checkDeclared as ct, SHAPE_KINDS as d, declaredClaimOf as dt, DeclaredClaim as et, SHAPE_KIND_IDS as f, declaredCounts as ft, ShapeInput as g, splitFolds as gt, ShapeGeometry as h, splitFileName as ht, JointMeasureId as i, FamilyCell as it, shapeLevel as j, marginSides as jt, shapeKindProblem as k, dropIndex as kt, DEFAULT_SHAPES as l, checkSplit as lt, ShapeCheck as m, leaveOneSeedOut as mt, JOINT_MEASURES as n, FAMILY_ANY_KIND as nt, Verdict as o, SplitCorpus as ot, ShapeBound as p, familyOf as pt, canonicalInput as q, JOINT_MOVED_MIN as r, FamilyBy as rt, compareMeasure as s, SplitFold as st, Direction as t, Declares as tt, RuleLevel as u, corpusHashOf as ut, ShapeKindSpec as v, Point as vt, inputShapeLevel as w, Sides as wt, ShapeSupport as x, Ring as xt, ShapeLevel as y, Rect as yt, LayoutGenerator as z, snapRect as zt };
674
+ //# sourceMappingURL=measures-D5hOVn9j.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measures-D5hOVn9j.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/measures.ts"],"mappings":";KAGY;;cAGC,gBAAgB;UAEZ;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;;;iBAIK,OAAO,MAAM,YAAY;;iBAKzB,YAAY,MAAM,OAAO;;;;;iBAWzB,SAAS,MAAM,OAAO;;;;;;iBAWtB,UAAU,MAAM,MAAM,iBAAiB;;UAMtC;WACN;WACA;WACA;WACA;;;;;;KAOC;WACG;WAAuB;WAAoB;WAAoB;WAAoB;;WAEnF;WACA,QAAQ;WACR,iBAAiB;;WAEjB;WAAyB;WAAqB;WAAqB;;WACnE;WAA0B;WAAqB;WAAqB;WAAqB;;;KAG5F,kBAAkB;;iBAGd,YAAY,QAAQ,qBAAqB;;iBAOzC,KAAK,MAAM,MAAM,QAAQ,qBAAqB;;iBAM9C,SAAS,QAAQ,SAAS;;;;;iBA4B1B,WAAW,QAAQ;;iBAyBnB,UAAU,QAAQ,QAAQ,YAAY,aAAa;;;;;iBAoBnD,UAAU,GAAG,MAAM,GAAG;WAAkB;WAAoB;;;;;;;iBA2B5D,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG;;;;;;iBAU/C,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ;;iBASvD,qBAAqB,GAAG,OAAO,GAAG,OAAO,GAAG;;KAShD;;iBAGI,YAAY,WAAW,WAAW,MAAM;;;;;iBAQxC,aAAa,WAAW,WAAW,gBAAgB;;iBAanD,kBAAkB,GAAG,MAAM,G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YAAY,iBAAiB,SAAS;;;;;iBAQtC,YAAY,KAAK,YAAY;;;;;;;iBAW7B,QAAQ,KAAK;;iBAQb,aAAa,OAAO,KAAK,wBAAwB;;iBAMjD,YAAY,OAAO,KAAK,wBAAwB;;iBAMhD,iBAAiB,KAAK;;iBAWtB,SAAS,KAAK,KAAK,mCAAmC;;UAKrD;;;;;;WAMN;;;;;;;;iBASK,YAAY,OAAO,YAAY,eAAe,gBAAgB,UAAS,aAAkB;;KCtQ7F;;;;;;UAOK,YAAY;WAClB,IAAI;WACJ;WACA,WAAW;;WAEX;;WAEA;;WAEA;;WAEA;;WAEA;;;;;WAKA;aAAgC;;;WAEhC;;WAEA,kBAAkB;;;;;WAKlB,QAAQ;;;KAIP;;;;;cAqBC,yBAAyB,YAAY;;cAcrC;;KAGD;;;;;;iBAOI,YAAY,MAAM,KAAK,2BAA2B,YAAO;;;;;;;iBAezD,eAAe,mBAAmB,kBAAkB,MAAM,KAAK,0CAA0C"}
package/build/text.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as MeasureSpec } from "./measures-B_n_KDMd.js";
1
+ import { a as MeasureSpec } from "./measures-D5hOVn9j.js";
2
2
  /**
3
3
  * The advance function of a host: the width of a run of text in a font, in pixels.
4
4
  * A browser host gives `canvasAdvance(context)`. A test or a server host gives a function of a font file.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/layout-contract",
4
- "version": "0.9.4",
4
+ "version": "0.9.5",
5
5
  "description": "The shared contract of the packing and highways layout engines: the input and record formats, the turn rule, margins, tolerances and hard rules.",
6
6
  "keywords": [
7
7
  "layout",
@@ -60,6 +60,7 @@
60
60
  "vitest": "^5.0.3"
61
61
  },
62
62
  "dependencies": {
63
+ "@mark1russell7/predicates": "^0.1.1",
63
64
  "@mark1russell7/rigor-generators": "^0.1.8",
64
65
  "@mark1russell7/rigor-statistics": "^0.1.23",
65
66
  "@mark1russell7/strategy-space": "^0.0.2",
package/src/frame.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // The frames of a layout change (`docs/FRAMES.md`): the record `layout-frame/1`, the frame at a time between two layouts, and the move between two frames.
2
2
  // A frame is a layout at one time of a change. A caller can stop at a frame and start the next layout from it.
3
3
  import type { PlacedBox } from "./balance.ts";
4
+ import { boxCenterDistance } from "./geometry.ts";
4
5
  import type { Placement } from "./output.ts";
5
6
 
6
7
  /** The schema of a frame. */
@@ -141,7 +142,7 @@ export function frameMove(a: LayoutFrame, b: LayoutFrame): number {
141
142
  for (const q of b.boxes) {
142
143
  const p = before.get(q.id);
143
144
  if (p === undefined) continue;
144
- sum += Math.hypot(q.x + q.w / 2 - (p.x + p.w / 2), q.y + q.h / 2 - (p.y + p.h / 2));
145
+ sum += boxCenterDistance(p, q);
145
146
  }
146
147
  return sum;
147
148
  }
package/src/geometry.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { orient2dSign } from "@mark1russell7/predicates";
2
+
1
3
  /** A side of a box. The y axis points down, so `top` has the smallest y. */
2
4
  export type Side = "top" | "right" | "bottom" | "left";
3
5
 
@@ -77,8 +79,8 @@ export type Region =
77
79
  | { readonly kind: "rect"; readonly x: number; readonly y: number; readonly w: number; readonly h: number }
78
80
  | {
79
81
  readonly kind: "polygon";
80
- readonly points: readonly (readonly [number, number])[];
81
- readonly holes?: readonly (readonly (readonly [number, number])[])[];
82
+ readonly points: Ring;
83
+ readonly holes?: readonly Ring[];
82
84
  }
83
85
  | { readonly kind: "circle"; readonly cx: number; readonly cy: number; readonly r: number }
84
86
  | { readonly kind: "ellipse"; readonly cx: number; readonly cy: number; readonly rx: number; readonly ry: number };
@@ -185,27 +187,36 @@ function orient(a: Point, b: Point, c: Point): number {
185
187
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
186
188
  }
187
189
 
188
- /** This function tells if two numbers have opposite signs. Zero and NaN give false, so a touch at an end does not count. */
189
- function opposite(p: number, q: number): boolean {
190
- return (p < 0 && q > 0) || (p > 0 && q < 0);
190
+ /** This function gives the exact sign of the cross product of `ab` and `ac`, from `orient2dSign` of `@mark1russell7/predicates`. */
191
+ function side(a: Point, b: Point, c: Point): number {
192
+ return orient2dSign(a.x, a.y, b.x, b.y, c.x, c.y);
193
+ }
194
+
195
+ /** This function tells if each coordinate of the points is finite. */
196
+ function allFinite(...points: readonly Point[]): boolean {
197
+ return points.every((p) => Number.isFinite(p.x) && Number.isFinite(p.y));
191
198
  }
192
199
 
193
200
  /**
194
201
  * This function tells if the segments `ab` and `cd` cross at one point inside both of them.
195
202
  * Segments that only touch at an end, or that are collinear, do not cross. The test has no tolerance.
203
+ * The signs are exact, so an input that is almost collinear gets the correct answer. A coordinate that is not finite gives `false`.
196
204
  */
197
205
  export function segmentsCross(a: Point, b: Point, c: Point, d: Point): boolean {
198
- return opposite(orient(c, d, a), orient(c, d, b)) && opposite(orient(a, b, c), orient(a, b, d));
206
+ if (!allFinite(a, b, c, d)) return false;
207
+ return side(c, d, a) * side(c, d, b) === -1 && side(a, b, c) * side(a, b, d) === -1;
199
208
  }
200
209
 
201
210
  /**
202
211
  * This function gives the point where the segments `ab` and `cd` cross, or `undefined`.
203
212
  * It gives a point exactly when `segmentsCross` is true, so a touch at an end and collinear segments give `undefined`.
213
+ * The point comes from float cross products. For an input that is almost collinear, the point stays on `ab`.
204
214
  */
205
215
  export function crossingPoint(a: Point, b: Point, c: Point, d: Point): Point | undefined {
206
216
  if (!segmentsCross(a, b, c, d)) return undefined;
207
217
  const from = orient(c, d, a);
208
- const t = from / (from - orient(c, d, b));
218
+ const r = from / (from - orient(c, d, b));
219
+ const t = Number.isNaN(r) ? 0.5 : Math.min(1, Math.max(0, r));
209
220
  return { x: a.x + t * (b.x - a.x), y: a.y + t * (b.y - a.y) };
210
221
  }
211
222
 
@@ -218,6 +229,35 @@ export function pointSegmentDistance(p: Point, a: Point, b: Point): number {
218
229
  return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
219
230
  }
220
231
 
232
+ /** A ring of a polygon: its corners in order, as `[x, y]` pairs. The last corner connects to the first. */
233
+ export type Ring = readonly (readonly [number, number])[];
234
+
235
+ /** This function tells if the point (`x`, `y`) is inside a ring, by the even-odd rule. A ring can be concave. The answer for a point on the border can be each value. */
236
+ export function pointInRing(x: number, y: number, ring: Ring): boolean {
237
+ return pointInRings(x, y, [ring]);
238
+ }
239
+
240
+ /**
241
+ * This function tells if the point (`x`, `y`) is inside a set of rings, by the even-odd rule over all their sides.
242
+ * Thus a point inside the outer ring and inside a hole is out. The answer for a point on a border can be each value.
243
+ */
244
+ export function pointInRings(x: number, y: number, rings: readonly Ring[]): boolean {
245
+ let inside = false;
246
+ for (const ring of rings) {
247
+ for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
248
+ const [xi, yi] = ring[i]!;
249
+ const [xj, yj] = ring[j]!;
250
+ if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;
251
+ }
252
+ }
253
+ return inside;
254
+ }
255
+
256
+ /** This function gives the distance between the centers of two rectangles. */
257
+ export function boxCenterDistance(a: Rect, b: Rect): number {
258
+ return Math.hypot(b.x + b.w / 2 - (a.x + a.w / 2), b.y + b.h / 2 - (a.y + a.h / 2));
259
+ }
260
+
221
261
  /**
222
262
  * This function gives the index at which a point goes among the items of a list on the screen.
223
263
  * The reading order is the rows from top to bottom, and each row from left to right.
package/src/rules.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { boundsOf, grow, marginSides, overlapOf, type Margin, type Point, type Rect, type Region } from "./geometry.ts";
1
+ import { boundsOf, grow, marginSides, overlapOf, pointInRings, type Margin, type Point, type Rect, type Region } from "./geometry.ts";
2
2
  import type { LayoutBox, LayoutContainer, LayoutInput, Obstacle, PairGap, Port } from "./input.ts";
3
3
  import { applyPack, type PackOutput } from "./output.ts";
4
4
  import { SHAPE_KIND_IDS, shapeKindProblem, type ShapeSupport } from "./shapes.ts";
@@ -532,19 +532,6 @@ function clipMid(ax: number, ay: number, bx: number, by: number, r: Rect): reado
532
532
  return [ax + t * dx, ay + t * dy];
533
533
  }
534
534
 
535
- /** The even-odd rule over the outer ring and the holes. */
536
- function pointInRings(x: number, y: number, rings: readonly (readonly (readonly [number, number])[])[]): boolean {
537
- let inside = false;
538
- for (const ring of rings) {
539
- for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
540
- const [xi, yi] = ring[i]!;
541
- const [xj, yj] = ring[j]!;
542
- if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;
543
- }
544
- }
545
- return inside;
546
- }
547
-
548
535
  /**
549
536
  * This function counts the pairs of a placed box and an obstacle that overlap by more than `tolerance`.
550
537
  * The box counts with its margin. A box with a shape counts as its bounding box.
@@ -1 +0,0 @@
1
- {"version":3,"file":"measures-B_n_KDMd.d.ts","names":[],"sources":["../src/geometry.ts","../src/corpus.ts","../src/input.ts","../src/shapes.ts","../src/measures.ts"],"mappings":";KACY;;cAGC,gBAAgB;UAEZ;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;;;iBAIK,OAAO,MAAM,YAAY;;iBAKzB,YAAY,MAAM,OAAO;;;;;iBAWzB,SAAS,MAAM,OAAO;;;;;;iBAWtB,UAAU,MAAM,MAAM,iBAAiB;;UAMtC;WACN;WACA;WACA;WACA;;;;;;KAOC;WACG;WAAuB;WAAoB;WAAoB;WAAoB;;WAEnF;WACA;WACA;;WAEA;WAAyB;WAAqB;WAAqB;;WACnE;WAA0B;WAAqB;WAAqB;WAAqB;;;KAG5F,kBAAkB;;iBAGd,YAAY,QAAQ,qBAAqB;;iBAOzC,KAAK,MAAM,MAAM,QAAQ,qBAAqB;;iBAM9C,SAAS,QAAQ,SAAS;;;;;iBA4B1B,WAAW,QAAQ;;iBAyBnB,UAAU,QAAQ,QAAQ,YAAY,aAAa;;;;;iBAoBnD,UAAU,GAAG,MAAM,GAAG;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