reladraw 0.14.2 → 0.14.4
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/README.md +1 -1
- package/SYNTAX.md +13 -1
- package/dist/render.js +6 -2
- package/dist/search.js +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ That gets you a copy of the skill at the time you run it, so you'll need to re-r
|
|
|
82
82
|
|
|
83
83
|
## Status
|
|
84
84
|
|
|
85
|
-
Version 0.14.
|
|
85
|
+
Version 0.14.4. Early stage, but works. The parser, layout engine, and SVG renderer are written in TypeScript, with zero runtime dependencies. There is a command-line tool that turns a .reladraw text file into an SVG, and an element that does the same inside a web page.
|
|
86
86
|
|
|
87
87
|
The language isn't stable yet, so expect the syntax to change.
|
|
88
88
|
|
package/SYNTAX.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Syntax reference — 0.14.
|
|
1
|
+
# Syntax reference — 0.14.4
|
|
2
2
|
|
|
3
3
|
What the language accepts. The parser, resolver and SVG renderer implement all of it; the sections at the end record what is defective, unchecked or undecided.
|
|
4
4
|
|
|
@@ -1112,6 +1112,18 @@ That one was found by testing the lexer, not by rendering — and it could not h
|
|
|
1112
1112
|
|
|
1113
1113
|
Pre-1.0, so the minor number is where a breaking change goes. Every removal below is refused by name with the replacement quoted, rather than dropped in silence — an older file stops with an error saying what to write instead.
|
|
1114
1114
|
|
|
1115
|
+
**0.14.4**
|
|
1116
|
+
|
|
1117
|
+
No syntax changes, and no file that worked is refused. No example diagram draws differently.
|
|
1118
|
+
|
|
1119
|
+
- Faster: lines steered with `between` in a busy diagram. When looking for its way, such a line didn't account for the gap it still had to pass through, so it searched much of the diagram before finding it. A test diagram with four of them among forty-four other lines drew in 6.8 seconds, and now draws in about 5.5.
|
|
1120
|
+
|
|
1121
|
+
**0.14.3**
|
|
1122
|
+
|
|
1123
|
+
No syntax changes, and no file that worked is refused. No example diagram draws differently.
|
|
1124
|
+
|
|
1125
|
+
- A fix: many curved lines into one side could hang the page. With twenty-two copies of `edge a -> b from: right to: left`, some lines had no room left to curve before the arrowhead, and the tool kept trying ever smaller curves thousands of times. It now stops at the smallest, and the same file draws in a tenth of a second.
|
|
1126
|
+
|
|
1115
1127
|
**0.14.2**
|
|
1116
1128
|
|
|
1117
1129
|
No syntax changes, and no file that worked is refused.
|
package/dist/render.js
CHANGED
|
@@ -2738,9 +2738,13 @@ function sweptPath(points, boxes, neighbors, arrow, marks) {
|
|
|
2738
2738
|
const p3 = along(corner, dout, b);
|
|
2739
2739
|
return [p0, along(p0, din, a * kappa), along(p3, dout, -b * kappa), p3];
|
|
2740
2740
|
};
|
|
2741
|
+
// Within half a pixel of the smallest is the smallest: where an end piece
|
|
2742
|
+
// has no room left, the smallest is zero, which shrinking never reaches,
|
|
2743
|
+
// and twenty-two lines into one side took the page down.
|
|
2744
|
+
const shrink = (size) => (size * 0.85 < least + 0.5 ? least : size * 0.85);
|
|
2741
2745
|
while ((a > least || b > least) && !clear(...quarter(a, b))) {
|
|
2742
|
-
a =
|
|
2743
|
-
b =
|
|
2746
|
+
a = shrink(a);
|
|
2747
|
+
b = shrink(b);
|
|
2744
2748
|
}
|
|
2745
2749
|
curve(...quarter(a, b));
|
|
2746
2750
|
}
|
package/dist/search.js
CHANGED
|
@@ -106,10 +106,12 @@ export function searchRoute(start, end, walls, options) {
|
|
|
106
106
|
// way just as long can arrive later with a better tie-break; it keeps on
|
|
107
107
|
// until nothing waiting could come in as cheap as the end already has, and
|
|
108
108
|
// what it finds is exactly what searching every direction alike would.
|
|
109
|
+
// Until the line has passed its gate, that is by way of the gate.
|
|
109
110
|
const toGo = (current) => {
|
|
110
111
|
const cell = (current - (current % 8)) / 8;
|
|
111
112
|
const i = cell % width;
|
|
112
|
-
|
|
113
|
+
const point = { x: xs[i], y: ys[(cell - i) / width] };
|
|
114
|
+
return leastLength(point, back, current % 2 === 1 ? undefined : gate);
|
|
113
115
|
};
|
|
114
116
|
const heap = new MinHeap();
|
|
115
117
|
const begin = state(si, sj, first, 0);
|
|
@@ -196,6 +198,18 @@ export function searchRoute(start, end, walls, options) {
|
|
|
196
198
|
path.reverse();
|
|
197
199
|
return { points: straightRuns([start, ...path, end]), cost: cost[goal] };
|
|
198
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* The shortest a right-angled line from `a` to `b` could be: straight across
|
|
203
|
+
* and straight down, or with a gate, across to its line at `at` and to a
|
|
204
|
+
* level within it on the way.
|
|
205
|
+
*/
|
|
206
|
+
function leastLength(a, b, gate) {
|
|
207
|
+
if (!gate)
|
|
208
|
+
return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
|
|
209
|
+
const [u, v, bu, bv] = gate.run === 'x' ? [a.x, a.y, b.x, b.y] : [a.y, a.x, b.y, b.x];
|
|
210
|
+
const off = Math.max(0, gate.lo - Math.max(v, bv), Math.min(v, bv) - gate.hi);
|
|
211
|
+
return Math.abs(u - gate.at) + Math.abs(gate.at - bu) + Math.abs(v - bv) + 2 * off;
|
|
212
|
+
}
|
|
199
213
|
/**
|
|
200
214
|
* The tracks on one axis: beside each wall at `clear` where that is open,
|
|
201
215
|
* down the middle of every gap between walls, through the ends, and a lane
|