@orbat-mapper/tactical-draw 0.2.0-alpha.28 → 0.2.0-alpha.29
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 +4 -3
- package/dist/index.mjs +12 -6
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -76,8 +76,9 @@ declare function fillPatternImageDimension(pixelRatio: number): number;
|
|
|
76
76
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
77
77
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
78
78
|
* jsdom/node tests. Diagonal lines are snapped to slope ±1 (45°) so the
|
|
79
|
-
* mod-based coverage math in {@link lineCoverage} tiles exactly
|
|
80
|
-
*
|
|
79
|
+
* mod-based coverage math in {@link lineCoverage} tiles exactly. `"hachure"`
|
|
80
|
+
* draws the "/" diagonal, `"backhachure"` its "\" mirror, and `"cross"` unions
|
|
81
|
+
* both via `Math.max` coverage.
|
|
81
82
|
*/
|
|
82
83
|
declare function makeFillPatternImage(color: string, pattern: HatchPattern, pixelRatio?: number): {
|
|
83
84
|
width: number;
|
|
@@ -149,7 +150,7 @@ interface HandleStyle {
|
|
|
149
150
|
fillColor?: string;
|
|
150
151
|
/**
|
|
151
152
|
* How `fillColor` paints a filled part's interior. Absent or `"solid"` is
|
|
152
|
-
* today's flat fill; `"hachure"`/`"cross"` request the shared hatch texture
|
|
153
|
+
* today's flat fill; `"hachure"`/`"backhachure"`/`"cross"` request the shared hatch texture
|
|
153
154
|
* ({@link makeFillPatternImage}). Alpha rides in `fillColor` — there is no
|
|
154
155
|
* separate opacity field. Adapters that cannot rasterize a pattern degrade
|
|
155
156
|
* to solid. Per-feature only: layer-level `StyleOptions` has no equivalent.
|
package/dist/index.mjs
CHANGED
|
@@ -6099,7 +6099,11 @@ function resolveSlot(adapter, supplied, owned) {
|
|
|
6099
6099
|
* to {@link HatchPattern}, so adapters can test membership and build filter
|
|
6100
6100
|
* expressions without re-spelling the pattern vocabulary.
|
|
6101
6101
|
*/
|
|
6102
|
-
const HATCH_PATTERNS = [
|
|
6102
|
+
const HATCH_PATTERNS = [
|
|
6103
|
+
"hachure",
|
|
6104
|
+
"backhachure",
|
|
6105
|
+
"cross"
|
|
6106
|
+
];
|
|
6103
6107
|
/** Tile edge length, CSS px, before `pixelRatio` scaling. Kept a power of two. */
|
|
6104
6108
|
const BASE_TILE_SIZE = 32;
|
|
6105
6109
|
/** Line spacing as a fraction of the tile edge — 4 repeats per tile. */
|
|
@@ -6184,8 +6188,9 @@ const SQRT2 = Math.SQRT2;
|
|
|
6184
6188
|
/**
|
|
6185
6189
|
* Coverage in `[0, 1]` of one diagonal line family (slope +1 or -1, both
|
|
6186
6190
|
* period `spacing`) at pixel center `(x, y)`, antialiased over a ~1 device-px
|
|
6187
|
-
* band. `axis` selects `y - x` (the "/" hachure) or `y + x` (
|
|
6188
|
-
*
|
|
6191
|
+
* band. `axis` selects `y - x` (the "/" hachure) or `y + x` (the "\" mirror,
|
|
6192
|
+
* "backhachure", which "cross" unions on top of the hachure). Because `spacing`
|
|
6193
|
+
* divides the tile dimension evenly, shifting
|
|
6189
6194
|
* `x` or `y` by a whole tile is a whole number of `spacing` periods, so the
|
|
6190
6195
|
* mod-distance — and therefore the coverage — is identical at the tile edges
|
|
6191
6196
|
* as at their wrapped continuation. That periodicity is what makes the tile
|
|
@@ -6201,8 +6206,9 @@ function lineCoverage(x, y, spacing, lineWidth, axis) {
|
|
|
6201
6206
|
* Rasterize one seamless hatch tile as a straight RGBA pixel buffer — no
|
|
6202
6207
|
* canvas involved, so this runs identically in a browser adapter and in
|
|
6203
6208
|
* jsdom/node tests. Diagonal lines are snapped to slope ±1 (45°) so the
|
|
6204
|
-
* mod-based coverage math in {@link lineCoverage} tiles exactly
|
|
6205
|
-
*
|
|
6209
|
+
* mod-based coverage math in {@link lineCoverage} tiles exactly. `"hachure"`
|
|
6210
|
+
* draws the "/" diagonal, `"backhachure"` its "\" mirror, and `"cross"` unions
|
|
6211
|
+
* both via `Math.max` coverage.
|
|
6206
6212
|
*/
|
|
6207
6213
|
function makeFillPatternImage(color, pattern, pixelRatio = 1) {
|
|
6208
6214
|
const size = fillPatternImageDimension(pixelRatio);
|
|
@@ -6213,7 +6219,7 @@ function makeFillPatternImage(color, pattern, pixelRatio = 1) {
|
|
|
6213
6219
|
for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
|
|
6214
6220
|
const cx = x + .5;
|
|
6215
6221
|
const cy = y + .5;
|
|
6216
|
-
let coverage = lineCoverage(cx, cy, spacing, lineWidth, "/");
|
|
6222
|
+
let coverage = pattern === "backhachure" ? lineCoverage(cx, cy, spacing, lineWidth, "\\") : lineCoverage(cx, cy, spacing, lineWidth, "/");
|
|
6217
6223
|
if (pattern === "cross") coverage = Math.max(coverage, lineCoverage(cx, cy, spacing, lineWidth, "\\"));
|
|
6218
6224
|
const i = (y * size + x) * 4;
|
|
6219
6225
|
data[i] = r;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.29",
|
|
4
4
|
"description": "Engine-agnostic draw/edit core for tactical control measures (MIL-STD-2525 / APP-6). The MapAdapter ABI and bring-your-own-engine entry point for the tactical-draw package family.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@orbat-mapper/control-measures": "^0.2.0-alpha.
|
|
41
|
+
"@orbat-mapper/control-measures": "^0.2.0-alpha.21"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@arethetypeswrong/core": "^0.18.3",
|