@packtrack/layout 1.0.9 → 1.0.11
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/.built/device/channel.js +5 -1
- package/.built/device/device.js +5 -1
- package/.built/district.js +7 -3
- package/.built/layout.js +29 -25
- package/.built/position.js +5 -1
- package/.built/positioner/index.js +5 -1
- package/.built/positioner/point.js +6 -2
- package/.built/positioner/responder-type.js +5 -1
- package/.built/power-district.js +5 -1
- package/.built/route.js +5 -1
- package/.built/router.js +5 -1
- package/.built/section.js +12 -8
- package/.built/source/device/channel.d.ts +8 -0
- package/.built/source/device/channel.js +16 -0
- package/.built/source/device/device.d.ts +11 -0
- package/.built/source/device/device.js +24 -0
- package/.built/source/district.d.ts +20 -0
- package/.built/source/district.js +86 -0
- package/.built/source/layout.d.ts +29 -0
- package/.built/source/layout.js +286 -0
- package/.built/source/position.d.ts +10 -0
- package/.built/source/position.js +33 -0
- package/.built/source/power-district.d.ts +8 -0
- package/.built/source/power-district.js +18 -0
- package/.built/source/route.d.ts +10 -0
- package/.built/source/route.js +17 -0
- package/.built/source/router.d.ts +14 -0
- package/.built/source/router.js +40 -0
- package/.built/source/section.d.ts +40 -0
- package/.built/source/section.js +217 -0
- package/.built/source/tile.d.ts +57 -0
- package/.built/source/tile.js +78 -0
- package/.built/source/track.d.ts +12 -0
- package/.built/source/track.js +29 -0
- package/.built/tile.js +7 -2
- package/.built/track.js +7 -3
- package/package.json +1 -1
- package/source/index.ts +3 -0
- package/.built/index.d.ts +0 -9
- package/.built/index.js +0 -9
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Section = void 0;
|
|
4
|
+
const position_1 = require("./position");
|
|
5
|
+
const router_1 = require("./router");
|
|
6
|
+
class Section {
|
|
7
|
+
name;
|
|
8
|
+
district;
|
|
9
|
+
powerDistrict;
|
|
10
|
+
tracks = [];
|
|
11
|
+
tiles = [];
|
|
12
|
+
in;
|
|
13
|
+
out;
|
|
14
|
+
constructor(name, district) {
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.district = district;
|
|
17
|
+
}
|
|
18
|
+
get domainName() {
|
|
19
|
+
return `${this.name}.${this.district.domainName}`;
|
|
20
|
+
}
|
|
21
|
+
// returns the next currently set section
|
|
22
|
+
next(reverse) {
|
|
23
|
+
if (reverse) {
|
|
24
|
+
if (!this.in) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (this.in instanceof Section) {
|
|
28
|
+
return this.in;
|
|
29
|
+
}
|
|
30
|
+
if (this.in instanceof router_1.Router) {
|
|
31
|
+
const activeRoute = this.in.activeRoute;
|
|
32
|
+
if (!activeRoute) {
|
|
33
|
+
throw new Error(`Router '${this.in.domainName}' has no active route`);
|
|
34
|
+
}
|
|
35
|
+
if (activeRoute.in == this) {
|
|
36
|
+
return activeRoute.out;
|
|
37
|
+
}
|
|
38
|
+
if (activeRoute.out == this) {
|
|
39
|
+
return activeRoute.in;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Router '${this.in.domainName}' is not routing from '${this.domainName}'`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (!this.out) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (this.out instanceof Section) {
|
|
49
|
+
return this.out;
|
|
50
|
+
}
|
|
51
|
+
if (this.out instanceof router_1.Router) {
|
|
52
|
+
const activeRoute = this.out.activeRoute;
|
|
53
|
+
if (!activeRoute) {
|
|
54
|
+
throw new Error(`Router '${this.out.domainName}' has no active route`);
|
|
55
|
+
}
|
|
56
|
+
if (activeRoute.in == this) {
|
|
57
|
+
return activeRoute.out;
|
|
58
|
+
}
|
|
59
|
+
if (activeRoute.out == this) {
|
|
60
|
+
return activeRoute.in;
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`Router '${this.in?.domainName}' is not routing from '${this.domainName}'`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
getTilesInRange(startPosition, endPosition) {
|
|
67
|
+
if (startPosition.section != this && endPosition.section != this) {
|
|
68
|
+
return {
|
|
69
|
+
offset: {
|
|
70
|
+
start: 0,
|
|
71
|
+
end: this.tiles[this.tiles.length - 1].pattern.length
|
|
72
|
+
},
|
|
73
|
+
tiles: [...this.tiles]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
let start = 0;
|
|
77
|
+
let end = this.length;
|
|
78
|
+
// only use the position limit if it is within our section
|
|
79
|
+
if (startPosition.section == this) {
|
|
80
|
+
end = startPosition.absolutePosition;
|
|
81
|
+
}
|
|
82
|
+
if (endPosition.section == this) {
|
|
83
|
+
start = endPosition.absolutePosition;
|
|
84
|
+
}
|
|
85
|
+
// flip if the range was reversed
|
|
86
|
+
if (end < start) {
|
|
87
|
+
const small = end;
|
|
88
|
+
end = start;
|
|
89
|
+
start = small;
|
|
90
|
+
}
|
|
91
|
+
let passed = 0;
|
|
92
|
+
const tiles = [];
|
|
93
|
+
const tileUnitLength = this.length / this.tileLength;
|
|
94
|
+
const offset = {
|
|
95
|
+
start: 0,
|
|
96
|
+
end: 0
|
|
97
|
+
};
|
|
98
|
+
for (let tile of this.tiles) {
|
|
99
|
+
const length = tile.pattern.length * tileUnitLength;
|
|
100
|
+
if (start - length <= passed && end + length >= passed) {
|
|
101
|
+
tiles.push(tile);
|
|
102
|
+
if (start <= passed) {
|
|
103
|
+
offset.start = (start + length - passed) * tile.pattern.length / length;
|
|
104
|
+
}
|
|
105
|
+
if (end >= passed) {
|
|
106
|
+
offset.end = 0.5; // (start + length - passed) * tile.pattern.length / length;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
passed += length;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
offset,
|
|
113
|
+
tiles
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
dump() {
|
|
117
|
+
console.group(`Section ${this.domainName}`);
|
|
118
|
+
console.log('in', this.in?.name ?? 'buffer');
|
|
119
|
+
console.log('out', this.out?.name ?? 'buffer');
|
|
120
|
+
console.group(`tracks`);
|
|
121
|
+
for (let track of this.tracks) {
|
|
122
|
+
track.dump();
|
|
123
|
+
}
|
|
124
|
+
console.groupEnd();
|
|
125
|
+
console.groupEnd();
|
|
126
|
+
}
|
|
127
|
+
get length() {
|
|
128
|
+
return this.tracks.reduce((accumulator, track) => accumulator + track.length, 0);
|
|
129
|
+
}
|
|
130
|
+
get tileLength() {
|
|
131
|
+
return this.tiles.reduce((accumulator, tile) => accumulator + tile.pattern.length, 0);
|
|
132
|
+
}
|
|
133
|
+
// follow the active path ahead (reverse = true = back)
|
|
134
|
+
// uses the currently set routes
|
|
135
|
+
// returns all touched sections
|
|
136
|
+
trail(offset, reversed, length) {
|
|
137
|
+
let tip = this;
|
|
138
|
+
const sections = [this];
|
|
139
|
+
if (reversed) {
|
|
140
|
+
length -= offset;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
length -= this.length - offset;
|
|
144
|
+
}
|
|
145
|
+
while (length > 0) {
|
|
146
|
+
let next;
|
|
147
|
+
if (reversed) {
|
|
148
|
+
next = tip.in;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
next = tip.out;
|
|
152
|
+
}
|
|
153
|
+
if (!next) {
|
|
154
|
+
return {
|
|
155
|
+
sections,
|
|
156
|
+
tip: new position_1.SectionPosition(tip, tip.length, false)
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (next instanceof Section) {
|
|
160
|
+
tip = next;
|
|
161
|
+
}
|
|
162
|
+
if (next instanceof router_1.Router) {
|
|
163
|
+
if (!next.activeRoute) {
|
|
164
|
+
throw new Error(`Router '${next.domainName}' has no active route (routes: ${next.routes.map(route => `'${route.name}'`).join(', ')})`);
|
|
165
|
+
}
|
|
166
|
+
// TODO: handle flipped cases
|
|
167
|
+
if (reversed) {
|
|
168
|
+
tip = next.activeRoute.in;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
tip = next.activeRoute.out;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
sections.push(tip);
|
|
175
|
+
length -= tip.length;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
sections,
|
|
179
|
+
tip: new position_1.SectionPosition(tip, reversed ? -length : tip.length + length, false)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
toDotReference() {
|
|
183
|
+
return `section_${this.name.replace(/-/g, '_')}_${this.district.toDotReference()}`;
|
|
184
|
+
}
|
|
185
|
+
toDotDefinition() {
|
|
186
|
+
return `
|
|
187
|
+
${this.toDotReference()} [ label = ${JSON.stringify(`${this.name}\n${this.length}`)}, shape = box ]
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
toDotConnection() {
|
|
191
|
+
return `
|
|
192
|
+
${this.out instanceof Section ? `${this.toDotReference()} -> ${this.out.toDotReference()}` : ''}
|
|
193
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
toSVG() {
|
|
196
|
+
return `
|
|
197
|
+
<g id=${JSON.stringify(this.domainName).split('.').join('_')}>
|
|
198
|
+
<style>
|
|
199
|
+
|
|
200
|
+
g#${this.domainName.split('.').join('_')} path {
|
|
201
|
+
stroke: hsl(${(this.length / this.tileLength)}deg, 100%, 50%);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
</style>
|
|
205
|
+
|
|
206
|
+
${this.tiles.map(tile => tile.toSVG()).join('')}
|
|
207
|
+
</g>
|
|
208
|
+
`;
|
|
209
|
+
}
|
|
210
|
+
findSVGPositions() {
|
|
211
|
+
return this.tiles.map(tile => ({
|
|
212
|
+
x: tile.x,
|
|
213
|
+
y: tile.y
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.Section = Section;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Section } from './section.js';
|
|
2
|
+
export declare class TilePattern {
|
|
3
|
+
length: number;
|
|
4
|
+
path: (continuous: boolean, x: number, y: number) => string;
|
|
5
|
+
static patterns: {
|
|
6
|
+
'tl-cc': TilePattern;
|
|
7
|
+
'tc-cc': TilePattern;
|
|
8
|
+
'tr-cc': TilePattern;
|
|
9
|
+
'cl-cc': TilePattern;
|
|
10
|
+
'cr-cc': TilePattern;
|
|
11
|
+
'bl-cc': TilePattern;
|
|
12
|
+
'bc-cc': TilePattern;
|
|
13
|
+
'br-cc': TilePattern;
|
|
14
|
+
'cc-tl': TilePattern;
|
|
15
|
+
'cc-tc': TilePattern;
|
|
16
|
+
'cc-tr': TilePattern;
|
|
17
|
+
'cc-cl': TilePattern;
|
|
18
|
+
'cc-cr': TilePattern;
|
|
19
|
+
'cc-bl': TilePattern;
|
|
20
|
+
'cc-bc': TilePattern;
|
|
21
|
+
'cc-br': TilePattern;
|
|
22
|
+
'cr-cl': TilePattern;
|
|
23
|
+
'cr-tl': TilePattern;
|
|
24
|
+
'cr-bl': TilePattern;
|
|
25
|
+
'cl-cr': TilePattern;
|
|
26
|
+
'cl-tr': TilePattern;
|
|
27
|
+
'cl-bl': TilePattern;
|
|
28
|
+
'tl-bc': TilePattern;
|
|
29
|
+
'tl-br': TilePattern;
|
|
30
|
+
'tl-cr': TilePattern;
|
|
31
|
+
'tc-bc': TilePattern;
|
|
32
|
+
'tc-br': TilePattern;
|
|
33
|
+
'tc-bl': TilePattern;
|
|
34
|
+
'tr-cl': TilePattern;
|
|
35
|
+
'tr-bc': TilePattern;
|
|
36
|
+
'bl-tr': TilePattern;
|
|
37
|
+
'bl-tc': TilePattern;
|
|
38
|
+
'bl-cr': TilePattern;
|
|
39
|
+
'bc-tc': TilePattern;
|
|
40
|
+
'bc-tr': TilePattern;
|
|
41
|
+
'bc-tl': TilePattern;
|
|
42
|
+
'br-cl': TilePattern;
|
|
43
|
+
'br-tc': TilePattern;
|
|
44
|
+
'br-tl': TilePattern;
|
|
45
|
+
'cl-bc': TilePattern;
|
|
46
|
+
};
|
|
47
|
+
constructor(length: number, path: (continuous: boolean, x: number, y: number) => string);
|
|
48
|
+
}
|
|
49
|
+
export declare class Tile {
|
|
50
|
+
section: Section;
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
pattern: TilePattern;
|
|
54
|
+
constructor(section: Section, x: number, y: number, pattern: TilePattern);
|
|
55
|
+
toSVGPath(continuous?: boolean): string;
|
|
56
|
+
toSVG(): string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tile = exports.TilePattern = void 0;
|
|
4
|
+
class TilePattern {
|
|
5
|
+
length;
|
|
6
|
+
path;
|
|
7
|
+
// TODO: replace simple paths with rounded versions
|
|
8
|
+
static patterns = {
|
|
9
|
+
'tl-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}`),
|
|
10
|
+
'tc-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 0.5}`),
|
|
11
|
+
'tr-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0}, L ${x + 0.5} ${y + 0.5}`),
|
|
12
|
+
'cl-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}`),
|
|
13
|
+
'cr-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}`),
|
|
14
|
+
'bl-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}`),
|
|
15
|
+
'bc-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}`),
|
|
16
|
+
'br-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}`),
|
|
17
|
+
'cc-tl': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
|
|
18
|
+
'cc-tc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
|
|
19
|
+
'cc-tr': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
|
|
20
|
+
'cc-cl': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
|
|
21
|
+
'cc-cr': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
|
|
22
|
+
'cc-bl': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 1}`),
|
|
23
|
+
'cc-bc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 1}`),
|
|
24
|
+
'cc-br': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
|
|
25
|
+
'cr-cl': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
|
|
26
|
+
'cr-tl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
|
|
27
|
+
'cr-bl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 1}`),
|
|
28
|
+
'cl-cr': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
|
|
29
|
+
'cl-tr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
|
|
30
|
+
'cl-bl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
|
|
31
|
+
'tl-bc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 1}`),
|
|
32
|
+
'tl-br': new TilePattern(1.4, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
|
|
33
|
+
'tl-cr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
|
|
34
|
+
'tc-bc': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 1}`),
|
|
35
|
+
'tc-br': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
|
|
36
|
+
'tc-bl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 1}`),
|
|
37
|
+
'tr-cl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
|
|
38
|
+
'tr-bc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 1}`),
|
|
39
|
+
'bl-tr': new TilePattern(1.4, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
|
|
40
|
+
'bl-tc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
|
|
41
|
+
'bl-cr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
|
|
42
|
+
'bc-tc': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
|
|
43
|
+
'bc-tr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
|
|
44
|
+
'bc-tl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
|
|
45
|
+
'br-cl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
|
|
46
|
+
'br-tc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
|
|
47
|
+
'br-tl': new TilePattern(1.4, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
|
|
48
|
+
// oddities
|
|
49
|
+
'cl-bc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 1}`)
|
|
50
|
+
};
|
|
51
|
+
constructor(length, path) {
|
|
52
|
+
this.length = length;
|
|
53
|
+
this.path = path;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TilePattern = TilePattern;
|
|
57
|
+
class Tile {
|
|
58
|
+
section;
|
|
59
|
+
x;
|
|
60
|
+
y;
|
|
61
|
+
pattern;
|
|
62
|
+
constructor(section, x, y, pattern) {
|
|
63
|
+
this.section = section;
|
|
64
|
+
this.x = x;
|
|
65
|
+
this.y = y;
|
|
66
|
+
this.pattern = pattern;
|
|
67
|
+
}
|
|
68
|
+
toSVGPath(continuous = false) {
|
|
69
|
+
return this.pattern.path(continuous, this.x, this.y);
|
|
70
|
+
}
|
|
71
|
+
toSVG() {
|
|
72
|
+
return `
|
|
73
|
+
<path d="${this.toSVGPath()}" />
|
|
74
|
+
${this.section.tiles[0] == this ? `<text x="${this.x}" y="${this.y}" font-size="0.2">${this.section.name}</text>` : ''}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.Tile = Tile;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Positioner } from "../positioner";
|
|
2
|
+
import { Section } from "./section";
|
|
3
|
+
import { SectionPosition } from "./position";
|
|
4
|
+
export declare class Track {
|
|
5
|
+
section: Section;
|
|
6
|
+
length: number;
|
|
7
|
+
path: string;
|
|
8
|
+
positioners: Positioner[];
|
|
9
|
+
constructor(section: Section, length: number, path: string);
|
|
10
|
+
get head(): SectionPosition;
|
|
11
|
+
dump(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Track = void 0;
|
|
4
|
+
const position_1 = require("./position");
|
|
5
|
+
class Track {
|
|
6
|
+
section;
|
|
7
|
+
length;
|
|
8
|
+
path;
|
|
9
|
+
positioners = [];
|
|
10
|
+
constructor(section, length, path) {
|
|
11
|
+
this.section = section;
|
|
12
|
+
this.length = length;
|
|
13
|
+
this.path = path;
|
|
14
|
+
}
|
|
15
|
+
// the start of the track within the section
|
|
16
|
+
get head() {
|
|
17
|
+
let offset = 0;
|
|
18
|
+
for (let track of this.section.tracks) {
|
|
19
|
+
if (track == this) {
|
|
20
|
+
return new position_1.SectionPosition(this.section, offset, false);
|
|
21
|
+
}
|
|
22
|
+
offset += track.length;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
dump() {
|
|
26
|
+
console.log(this.length);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Track = Track;
|
package/.built/tile.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tile = exports.TilePattern = void 0;
|
|
4
|
+
class TilePattern {
|
|
2
5
|
length;
|
|
3
6
|
path;
|
|
4
7
|
// TODO: replace simple paths with rounded versions
|
|
@@ -50,7 +53,8 @@ export class TilePattern {
|
|
|
50
53
|
this.path = path;
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
|
-
|
|
56
|
+
exports.TilePattern = TilePattern;
|
|
57
|
+
class Tile {
|
|
54
58
|
section;
|
|
55
59
|
x;
|
|
56
60
|
y;
|
|
@@ -71,3 +75,4 @@ export class Tile {
|
|
|
71
75
|
`;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
exports.Tile = Tile;
|
package/.built/track.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Track = void 0;
|
|
4
|
+
const position_1 = require("./position");
|
|
5
|
+
class Track {
|
|
3
6
|
section;
|
|
4
7
|
length;
|
|
5
8
|
path;
|
|
@@ -14,7 +17,7 @@ export class Track {
|
|
|
14
17
|
let offset = 0;
|
|
15
18
|
for (let track of this.section.tracks) {
|
|
16
19
|
if (track == this) {
|
|
17
|
-
return new SectionPosition(this.section, offset, false);
|
|
20
|
+
return new position_1.SectionPosition(this.section, offset, false);
|
|
18
21
|
}
|
|
19
22
|
offset += track.length;
|
|
20
23
|
}
|
|
@@ -23,3 +26,4 @@ export class Track {
|
|
|
23
26
|
console.log(this.length);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
29
|
+
exports.Track = Track;
|
package/package.json
CHANGED
package/source/index.ts
CHANGED
package/.built/index.d.ts
DELETED
package/.built/index.js
DELETED