@emberbox/ui 0.10.0 → 0.12.0
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/package.json +1 -1
- package/src/index.ts +9 -3
- package/src/symbols/abilities.ts +10 -8
- package/src/symbols/additional.ts +214 -0
- package/src/symbols/catalog.ts +79 -7
- package/src/symbols/hazmat.ts +320 -0
- package/src/symbols/signs.ts +179 -37
- package/src/symbols/svg.ts +74 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -35,12 +35,18 @@ export {
|
|
|
35
35
|
type MarkKind, type Organisation, type SvgElement, type SymbolShape, type SymbolSpec, type UnitSize,
|
|
36
36
|
} from './symbols/tactical'
|
|
37
37
|
export {
|
|
38
|
-
BASIC_FORMS, DRIVES, FLIGHTS, ORGANISATION_COLOURS, SIGN_ORGANISATIONS, SIGN_SIZES, SUPPLEMENTS, VEHICLE_BODIES,
|
|
39
|
-
tacticalSignTree, type BasicForm, type Drive, type Flight, type
|
|
40
|
-
type TacticalSignSpec, type VehicleBody,
|
|
38
|
+
BASIC_FORMS, DRIVES, FLIGHTS, ORGANISATION_COLOURS, SIGN_FIGURES, SIGN_ORGANISATIONS, SIGN_SIZES, SUPPLEMENTS, VEHICLE_BODIES,
|
|
39
|
+
tacticalSign, tacticalSignTree, type BasicForm, type Drive, type Flight, type SignFigure, type SignOrganisation, type SignSize,
|
|
40
|
+
type SignStyle, type Supplement, type TacticalSignSpec, type VehicleBody,
|
|
41
41
|
} from './symbols/signs'
|
|
42
42
|
export {CATALOG_SOURCE, TACTICAL_SIGN_CATALOG, catalogSignTree, type CatalogEntry} from './symbols/catalog'
|
|
43
43
|
export {ABILITIES, type Ability, type AbilityName, type AbilityPart} from './symbols/abilities'
|
|
44
|
+
export {ADDITIONAL_SIGNS, additionalSign, additionalSignTree, type AdditionalSign, type AdditionalSignName} from './symbols/additional'
|
|
45
|
+
export type {BoxPart} from './symbols/svg'
|
|
46
|
+
export {
|
|
47
|
+
DANGER_LABELS, DANGER_LABEL_PATTERNS, HAZARD_NUMBER, UN_NUMBER, dangerLabel, dangerLabelTree, environmentMark, environmentMarkTree,
|
|
48
|
+
warningPanel, warningPanelTree, type DangerLabel, type DangerLabelPattern, type WarningPanel,
|
|
49
|
+
} from './symbols/hazmat'
|
|
44
50
|
|
|
45
51
|
/**
|
|
46
52
|
* Vue plugin that installs Nuxt UI in the Emberbox style. Icons come only from the bundled set; a
|
package/src/symbols/abilities.ts
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* their artwork.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import type {BoxPart} from './svg'
|
|
10
|
+
|
|
9
11
|
/** One stroke, filled shape or piece of writing of an ability, on the 100 × 60 box. */
|
|
10
|
-
export type AbilityPart =
|
|
11
|
-
| {d: string, filled?: boolean, width?: number}
|
|
12
|
-
| {circle: [number, number, number], filled?: boolean}
|
|
13
|
-
| {text: string, x: number, y: number, size: number}
|
|
12
|
+
export type AbilityPart = BoxPart
|
|
14
13
|
|
|
15
14
|
/** An ability of chapter 4 with its number, name after the recommendations and printed page. */
|
|
16
15
|
export interface Ability {
|
|
@@ -24,13 +23,16 @@ export interface Ability {
|
|
|
24
23
|
|
|
25
24
|
const CBRN: AbilityPart[] = [{circle: [34, 10, 6], filled: true}, {circle: [66, 10, 6], filled: true}, {d: 'M34 10 L68 54 M66 10 L32 54'}]
|
|
26
25
|
/** A wavy line at a height, from one x to another in waves of 10. */
|
|
27
|
-
function waves(y: number, from = 30, to = 70): AbilityPart {
|
|
26
|
+
export function waves(y: number, from = 30, to = 70): AbilityPart {
|
|
28
27
|
const more = Math.max(0, Math.round((to - from) / 10) - 1)
|
|
29
28
|
return {d: `M${from} ${y} q5 -5 10 0${' t10 0'.repeat(more)}`}
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
/** A diamond around a point. */
|
|
31
|
+
export const DIAMOND = (cx: number, cy: number, r: number): AbilityPart => ({d: `M${cx} ${cy - r} L${cx + r} ${cy} L${cx} ${cy + r} L${cx - r} ${cy} Z`})
|
|
32
|
+
/** The V of veterinary care. */
|
|
33
|
+
export const VET: AbilityPart = {d: 'M36 6 H44 L56 54 L68 6 H76'}
|
|
34
|
+
/** An open arrow head at a point, pointing along (dx, dy). */
|
|
35
|
+
export const ARROW_HEAD = (x: number, y: number, dx: number, dy: number): AbilityPart => ({d: `M${x - dx * 6 - dy * 4} ${y - dy * 6 + dx * 4} L${x} ${y} L${x - dx * 6 + dy * 4} ${y - dy * 6 - dx * 4}`})
|
|
34
36
|
|
|
35
37
|
/** The abilities of chapter 4, keyed by a short English name. */
|
|
36
38
|
export const ABILITIES = {
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The additional signs of chapter 5 of the recommendations "Taktische Zeichen im
|
|
3
|
+
* Bevölkerungsschutz" (BBK, 2024) that stand on their own rather than inside a basic form:
|
|
4
|
+
* directions and movements (5.2), administrative levels (5.7) and the signs of hazards and damage
|
|
5
|
+
* (5.8). Each is drawn on its own 100 × 60 box in the colours 5.8 recommends: people and units
|
|
6
|
+
* black, damage and hazards red, water and own forces blue. The drawings follow the system of the
|
|
7
|
+
* recommendations without copying their artwork.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {ARROW_HEAD, DIAMOND, VET, waves} from './abilities'
|
|
11
|
+
import {BLACK, HAZARD_RED as RED, MEASURE_BLUE as BLUE, WHITE, asterisk, boxPart, canvas, group, renderSvg, round, starOffsets, type BoxPart, type SvgElement} from './svg'
|
|
12
|
+
|
|
13
|
+
/** An additional sign with its number, name after the recommendations and printed page. */
|
|
14
|
+
export interface AdditionalSign {
|
|
15
|
+
number: string
|
|
16
|
+
name: string
|
|
17
|
+
page: number
|
|
18
|
+
parts: readonly BoxPart[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The green of 5.8.2, taken from the printed signs; annex O names no green for it. */
|
|
22
|
+
const GREEN = '#2E9E3E'
|
|
23
|
+
|
|
24
|
+
const red = (part: BoxPart): BoxPart => ({...part, colour: RED})
|
|
25
|
+
const blue = (part: BoxPart): BoxPart => ({...part, colour: BLUE})
|
|
26
|
+
|
|
27
|
+
/** A block arrow of the tactics of 5.8.1, starting at `x` and 56 long. */
|
|
28
|
+
function tacticArrow(x: number): BoxPart {
|
|
29
|
+
return {d: `M${x} 22 Q${x + 18} 14 ${x + 36} 16 V8 L${x + 56} 28 L${x + 36} 48 V40 Q${x + 18} 38 ${x} 48`}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const TRIANGLE: BoxPart = {d: 'M50 4 L80 56 H20 Z'}
|
|
33
|
+
const PERSON = DIAMOND(50, 30, 22)
|
|
34
|
+
|
|
35
|
+
/** A hazard of 5.8.1: a red triangle around its mark. */
|
|
36
|
+
function hazard(...inside: BoxPart[]): BoxPart[] {
|
|
37
|
+
return [TRIANGLE, ...inside].map(red)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A person of 5.8.8 moved up to make room for a mark below. */
|
|
41
|
+
const RAISED = DIAMOND(50, 26, 20)
|
|
42
|
+
|
|
43
|
+
/** A grade of activity or failure of 5.8.2: a square with `red` of its four quarters red, clockwise from the upper right. */
|
|
44
|
+
function activity(red: number): BoxPart[] {
|
|
45
|
+
const quarters = ['M50 8 H72 V30 H50 Z', 'M50 30 H72 V52 H50 Z', 'M28 30 H50 V52 H28 Z', 'M28 8 H50 V30 H28 Z']
|
|
46
|
+
return [
|
|
47
|
+
...quarters.map((d, index) => ({d, filled: true, width: 0.1, colour: index < red ? RED : GREEN})),
|
|
48
|
+
{d: 'M28 8 H72 V52 H28 Z'},
|
|
49
|
+
{circle: [50, 30, 8], filled: true, colour: WHITE},
|
|
50
|
+
{circle: [50, 30, 8]},
|
|
51
|
+
{text: String(red), x: 50, y: 30, size: 12},
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** A grade of destruction of 5.8.4: as many red strokes each way as the grade. */
|
|
56
|
+
function destruction(grade: number): BoxPart[] {
|
|
57
|
+
const offsets = grade === 1 ? [0] : grade === 2 ? [-6, 6] : [-9, 0, 9]
|
|
58
|
+
const step = (o: number) => round(o * Math.SQRT1_2)
|
|
59
|
+
const lines = offsets.flatMap(o => [
|
|
60
|
+
`M${34 + step(o)} ${14 - step(o)} L${66 + step(o)} ${46 - step(o)}`,
|
|
61
|
+
`M${66 + step(o)} ${14 + step(o)} L${34 + step(o)} ${46 + step(o)}`,
|
|
62
|
+
])
|
|
63
|
+
return [{d: lines.join(' '), colour: RED}]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A phase of a fire of 5.8.5: one to three red flames on a common base. */
|
|
67
|
+
function fire(phase: number): BoxPart[] {
|
|
68
|
+
const left = 50 - phase * 7
|
|
69
|
+
const flames = Array.from({length: phase}, (_, index) => `M${left + index * 14} 50 L${left + index * 14 + 14} 12 V50`).join(' ')
|
|
70
|
+
return [{d: `${flames} M${left} 50 H${left + phase * 14}`, colour: RED}]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A tendency of 5.8.3: an arrow in a square. */
|
|
74
|
+
function tendency(from: [number, number], to: [number, number]): BoxPart[] {
|
|
75
|
+
const length = Math.hypot(to[0] - from[0], to[1] - from[1])
|
|
76
|
+
return [{d: 'M30 10 H70 V50 H30 Z'}, {d: `M${from[0]} ${from[1]} L${to[0]} ${to[1]}`},
|
|
77
|
+
ARROW_HEAD(to[0], to[1], (to[0] - from[0]) / length, (to[1] - from[1]) / length)]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Three of a weather mark side by side. */
|
|
81
|
+
function three(mark: (x: number) => string): BoxPart {
|
|
82
|
+
return {d: [32, 50, 68].map(mark).join(' ')}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The stars of an administrative level of 5.7. */
|
|
86
|
+
function stars(level: number): BoxPart[] {
|
|
87
|
+
const r = level === 6 ? 5 : 6
|
|
88
|
+
return starOffsets(level).map(([dx, dy]) => ({d: asterisk(round(50 + dx * 1.4), round(30 + dy * 1.4), r)}))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The additional signs of chapter 5, keyed by a short English name, in the order of the recommendations. */
|
|
92
|
+
export const ADDITIONAL_SIGNS = {
|
|
93
|
+
'advance': {number: '5.2.1', name: 'Richtung des Vortragens einer Maßnahme', page: 35,
|
|
94
|
+
parts: [{d: 'M14 25 H74 M14 35 H74'}, {d: 'M68 16 L84 30 L68 44'}]},
|
|
95
|
+
'movement-start': {number: '5.2.2', name: 'Beginn einer Bewegung', page: 35, parts: [{d: 'M16 20 V40 M16 30 H82'}, ARROW_HEAD(82, 30, 1, 0)]},
|
|
96
|
+
'direction': {number: '5.2.3', name: 'Richtung, gerichtete Bewegung, Verbindung', page: 35, parts: [{d: 'M16 30 H82'}, ARROW_HEAD(82, 30, 1, 0)]},
|
|
97
|
+
'two-ways': {number: '5.2.4', name: 'Bewegung in zwei Richtungen (z. B. Sichten, Ordnen, Verteilen)', page: 35,
|
|
98
|
+
parts: [{d: 'M16 30 H84'}, ARROW_HEAD(84, 30, 1, 0), ARROW_HEAD(16, 30, -1, 0)]},
|
|
99
|
+
'movement-end': {number: '5.2.5', name: 'Ende einer Bewegung', page: 35, parts: [{d: 'M16 30 H82 M84 20 V40'}, ARROW_HEAD(82, 30, 1, 0)]},
|
|
100
|
+
'gathering': {number: '5.2.6', name: 'Sammeln, Zusammenführen', page: 35, parts: [{d: 'M14 30 H60'}, ARROW_HEAD(60, 30, 1, 0), {circle: [71, 30, 10]}]},
|
|
101
|
+
|
|
102
|
+
'municipality': {number: '5.7.1', name: 'Gemeinde, kreisangehörige Stadt, Amt', page: 40, parts: stars(1)},
|
|
103
|
+
'district': {number: '5.7.2', name: 'Kreis / Landkreis, kreisfreie Stadt', page: 40, parts: stars(2)},
|
|
104
|
+
'region': {number: '5.7.3', name: 'Bezirk / Regierungspräsidium', page: 40, parts: stars(3)},
|
|
105
|
+
'state': {number: '5.7.4', name: 'Bundesland / Freistaat', page: 40, parts: stars(4)},
|
|
106
|
+
'nation': {number: '5.7.5', name: 'Nationalstaat', page: 40, parts: stars(5)},
|
|
107
|
+
'european-union': {number: '5.7.6', name: 'Europäische Union', page: 40, parts: stars(6)},
|
|
108
|
+
|
|
109
|
+
'rescue': {number: '5.8.1.1', name: 'Einsatztaktik: Retten', page: 41, parts: [red({d: 'M22 8 L14 12 V48 L22 52'}), blue(tacticArrow(24))]},
|
|
110
|
+
'attack': {number: '5.8.1.2', name: 'Einsatztaktik: Angreifen', page: 41, parts: [blue(tacticArrow(14)), red({d: 'M76 8 L84 12 V48 L76 52'})]},
|
|
111
|
+
'defend': {number: '5.8.1.3', name: 'Einsatztaktik: Verteidigen', page: 41, parts: [red(tacticArrow(12)), blue({d: 'M86 8 L76 14 V46 L86 52'})]},
|
|
112
|
+
'retreat': {number: '5.8.1.4', name: 'Einsatztaktik: Rückzug', page: 41, parts: [red({d: 'M14 8 L22 12 V48 L14 52'}), blue(tacticArrow(30))]},
|
|
113
|
+
'flooded': {number: '5.8.1.5', name: 'überschwemmtes Gebiet', page: 41, parts: [
|
|
114
|
+
{d: 'M10 30 A40 26 0 1 0 90 30 A40 26 0 1 0 10 30 Z'}, waves(16, 32, 68), waves(46, 32, 68), waves(32, 16, 36), waves(32, 64, 84),
|
|
115
|
+
{text: 'W', x: 50, y: 30, size: 16},
|
|
116
|
+
].map(blue)},
|
|
117
|
+
'water-ingress': {number: '5.8.1.6', name: 'Gefahr durch Wassereinbruch', page: 41, parts: [TRIANGLE, waves(38, 36, 64), waves(46, 36, 64)].map(blue)},
|
|
118
|
+
'dangerous-goods': {number: '5.8.1.7', name: 'gefährliche Stoffe, z. B. GS, Chlor', page: 41, parts: hazard({text: 'GS', x: 50, y: 42, size: 16})},
|
|
119
|
+
'radioactivity': {number: '5.8.1.8', name: 'Gefahr durch Radioaktivität', page: 41, parts: hazard(
|
|
120
|
+
{d: 'M50 40 L55.5 49.5 A11 11 0 0 1 44.5 49.5 Z M50 40 L55.5 30.5 A11 11 0 0 1 61 40 Z M50 40 L39 40 A11 11 0 0 1 44.5 30.5 Z', filled: true},
|
|
121
|
+
)},
|
|
122
|
+
'electricity': {number: '5.8.1.9', name: 'Gefahr durch elektrische Energie', page: 42,
|
|
123
|
+
parts: hazard({d: 'M54 22 L46 38 H56 L49 52'}, ARROW_HEAD(49, 52, -0.45, 0.9))},
|
|
124
|
+
'mineral-oil': {number: '5.8.1.10', name: 'Gefahr durch Mineralöl', page: 42, parts: hazard({text: 'Ö', x: 50, y: 42, size: 16})},
|
|
125
|
+
'explosion': {number: '5.8.1.11', name: 'Gefahr durch Explosion', page: 42, parts: hazard({text: 'Ex', x: 50, y: 42, size: 16})},
|
|
126
|
+
'explosives': {number: '5.8.1.12', name: 'Gefahr durch explosionsfähige Kampfmittel oder Explosivstoffe', page: 42,
|
|
127
|
+
parts: hazard({circle: [50, 41, 4], filled: true}, {circle: [50, 41, 9]}, {d: 'M50 26 V29 M40 31 L42 33 M60 31 L58 33'})},
|
|
128
|
+
'presumed': {number: '5.8.1.13', name: 'Hinweis auf Vermutung oder unbestätigte Information/Gefahr', page: 42,
|
|
129
|
+
parts: [red({text: '?', x: 50, y: 30, size: 40})]},
|
|
130
|
+
'acute': {number: '5.8.1.14', name: 'Hinweis auf akute Situation; aktuell größte Gefahr', page: 42, parts: [red({text: '!', x: 50, y: 30, size: 40})]},
|
|
131
|
+
|
|
132
|
+
'activity-1': {number: '5.8.2.1', name: 'geringfügig erhöhte Aktivität; bis 25 % Ausfall; Einsatzwert bei 75 %', page: 43, parts: activity(1)},
|
|
133
|
+
'activity-2': {number: '5.8.2.2', name: 'moderat erhöhte Aktivität; bis 50 % Ausfall; Einsatzwert bei 50 %', page: 43, parts: activity(2)},
|
|
134
|
+
'activity-3': {number: '5.8.2.3', name: 'deutlich erhöhte Aktivität; bis 75 % Ausfall; Einsatzwert bei 25 %', page: 43, parts: activity(3)},
|
|
135
|
+
'activity-4': {number: '5.8.2.4', name: 'stark erhöhte Aktivität; Totalausfall', page: 43, parts: activity(4)},
|
|
136
|
+
'rising': {number: '5.8.3.1', name: 'Tendenz steigend / zunehmend / ausdehnend', page: 43, parts: tendency([36, 44], [64, 16])},
|
|
137
|
+
'steady': {number: '5.8.3.2', name: 'Tendenz unverändert / gleichbleibend', page: 43, parts: tendency([36, 30], [64, 30])},
|
|
138
|
+
'falling': {number: '5.8.3.3', name: 'Tendenz fallend / abnehmend / verkleinernd', page: 43, parts: tendency([36, 16], [64, 44])},
|
|
139
|
+
'damaged': {number: '5.8.4.1', name: 'angeschlagen, beschädigt', page: 44, parts: destruction(1)},
|
|
140
|
+
'partly-destroyed': {number: '5.8.4.2', name: 'teilzerstört, teilweise zusammengebrochen', page: 44, parts: destruction(2)},
|
|
141
|
+
'destroyed': {number: '5.8.4.3', name: 'total zerstört, zusammengebrochen', page: 44, parts: destruction(3)},
|
|
142
|
+
'incipient-fire': {number: '5.8.5.1', name: 'Entstehungsbrand', page: 44, parts: fire(1)},
|
|
143
|
+
'developed-fire': {number: '5.8.5.2', name: 'fortentwickelter Brand', page: 44, parts: fire(2)},
|
|
144
|
+
'full-fire': {number: '5.8.5.3', name: 'Vollbrand', page: 44, parts: fire(3)},
|
|
145
|
+
|
|
146
|
+
'injured-animal': {number: '5.8.6.1', name: 'verletztes / erkranktes Tier', page: 45, parts: [VET, {d: 'M56 14 V40'}]},
|
|
147
|
+
'contaminated-animal': {number: '5.8.6.2', name: 'kontaminiertes Tier', page: 45,
|
|
148
|
+
parts: [VET, {d: 'M56 14 V40'}, {circle: [72, 4, 2.5], filled: true}, {circle: [84, 4, 2.5], filled: true}, {d: 'M72 4 L84 14 M84 4 L72 14'}]},
|
|
149
|
+
'dead-animal': {number: '5.8.6.3', name: 'totes Tier', page: 45, parts: [VET, {d: 'M56 2 V30 M50 10 H62'}]},
|
|
150
|
+
|
|
151
|
+
'sunny': {number: '5.8.7.1', name: 'sonnig', page: 45, parts: [{circle: [50, 30, 10]},
|
|
152
|
+
{d: 'M50 8 V14 M50 46 V52 M28 30 H34 M66 30 H72 M35 15 L39 19 M65 15 L61 19 M35 45 L39 41 M65 45 L61 41'}]},
|
|
153
|
+
'cloudy': {number: '5.8.7.2', name: 'wolkig', page: 45,
|
|
154
|
+
parts: [{d: 'M28 46 H72 Q84 46 82 34 Q80 24 70 26 Q66 12 52 14 Q40 14 38 26 Q24 24 22 36 Q22 46 28 46 Z'}]},
|
|
155
|
+
'cloud-cover': {number: '5.8.7.3', name: 'Bedeckungsgrad des Himmels in 1/8-Abstufungen, hier: 4/8 bewölkt', page: 45,
|
|
156
|
+
parts: [{circle: [50, 30, 16]}, {d: 'M50 14 A16 16 0 0 1 50 46 Z', filled: true}]},
|
|
157
|
+
'foggy': {number: '5.8.7.4', name: 'nebelig (ggf. in Kombination mit 5.8.7.2)', page: 45, parts: [{d: 'M26 22 H74 M26 30 H74 M26 38 H74'}]},
|
|
158
|
+
'rainy': {number: '5.8.7.5', name: 'regnerisch (in Kombination mit 5.8.7.2)', page: 45,
|
|
159
|
+
parts: [{d: [[38, 14], [54, 14], [70, 14], [34, 30], [50, 30], [66, 30], [30, 46], [46, 46], [62, 46]]
|
|
160
|
+
.map(([x, y]) => `M${x! + 3} ${y! - 6} L${x! - 3} ${y! + 6}`).join(' ')}]},
|
|
161
|
+
'hail': {number: '5.8.7.6', name: 'hagelnd (in Kombination mit 5.8.7.2)', page: 46,
|
|
162
|
+
parts: [three(x => `M${x + 2} 8 L${x} 20 M${x} 40 L${x - 2} 52`), ...[32, 50, 68].map(x => ({circle: [x, 30, 4]} as BoxPart))]},
|
|
163
|
+
'thunderstorm': {number: '5.8.7.7', name: 'gewittrig (in Kombination mit 5.8.7.2)', page: 46,
|
|
164
|
+
parts: [three(x => `M${x + 4} 10 L${x - 4} 30 H${x + 4} L${x - 3} 48`), ...[32, 50, 68].map(x => ARROW_HEAD(x - 3, 48, -0.35, 0.94))]},
|
|
165
|
+
'snowy': {number: '5.8.7.8', name: 'schneiend (in Kombination mit 5.8.7.2)', page: 46, parts: [three(x => asterisk(x, 30, 8))]},
|
|
166
|
+
'temperature': {number: '5.8.7.9', name: 'Temperatur (frostig/kalt/heiß/extrem)', page: 46,
|
|
167
|
+
parts: [{d: 'M44 38 V12 A6 6 0 0 1 56 12 V38 A9 9 0 1 1 44 38 Z'}, {d: 'M64 14 H74 M64 22 H74 M64 30 H74'}]},
|
|
168
|
+
'windy': {number: '5.8.7.10', name: 'windig (ggf. ergänzt um die Stärke in der Anzahl der Striche oder in Beaufort oder km/h)', page: 46,
|
|
169
|
+
parts: [{d: 'M18 40 H82 M22 40 L16 30 M30 40 L24 30 M38 40 L32 30'}, ARROW_HEAD(82, 40, 1, 0)]},
|
|
170
|
+
|
|
171
|
+
'unharmed': {number: '5.8.8.1', name: 'unverletzt, exponiert', page: 47, parts: [PERSON]},
|
|
172
|
+
'affected': {number: '5.8.8.2', name: 'betroffen', page: 47, parts: [PERSON, {text: 'B', x: 72, y: 10, size: 12}]},
|
|
173
|
+
'injured': {number: '5.8.8.3', name: 'verletzt', page: 47, parts: [PERSON, {d: 'M50 8 V52'}]},
|
|
174
|
+
'triage': {number: '5.8.8.4', name: 'verletzt, mit Angabe der Sichtungskategorie (SK I–IV)', page: 47,
|
|
175
|
+
parts: [PERSON, {d: 'M50 8 V52'}, {text: 'II', x: 34, y: 52, size: 12}]},
|
|
176
|
+
'transport-priority': {number: '5.8.8.5', name: 'verletzt, mit Transportpriorität', page: 47,
|
|
177
|
+
parts: [PERSON, {d: 'M50 8 V52'}, {text: 'TP', x: 72, y: 10, size: 12}]},
|
|
178
|
+
'contaminated': {number: '5.8.8.6', name: 'kontaminiert', page: 47,
|
|
179
|
+
parts: [PERSON, {d: 'M50 8 V52'}, {circle: [64, 4, 2.5], filled: true}, {circle: [76, 4, 2.5], filled: true}, {d: 'M64 4 L76 14 M76 4 L64 14'}]},
|
|
180
|
+
'dead': {number: '5.8.8.7', name: 'tot', page: 47, parts: [PERSON, {d: 'M50 8 V52 M39 19 H61'}]},
|
|
181
|
+
'missing': {number: '5.8.8.8', name: 'vermisst', page: 47, parts: [PERSON, {d: 'M24 26 L46 4 M76 34 L54 56'}]},
|
|
182
|
+
'in-water': {number: '5.8.8.9', name: 'in Wassergefahr', page: 47, parts: [DIAMOND(50, 34, 20), waves(8, 30, 70), waves(14, 30, 70)]},
|
|
183
|
+
'trapped': {number: '5.8.8.10', name: 'in Zwangslage (verschüttet / eingeklemmt / eingeschlossen)', page: 47,
|
|
184
|
+
parts: [DIAMOND(50, 34, 20), {d: 'M24 8 H76'}]},
|
|
185
|
+
'rescued': {number: '5.8.8.11', name: 'gerettet / befreit', page: 48, parts: [RAISED, {d: 'M24 54 H76'}]},
|
|
186
|
+
'awaiting-transport': {number: '5.8.8.12', name: 'zu transportieren, Transport noch ausstehend', page: 48,
|
|
187
|
+
parts: [RAISED, {d: 'M28 54 H76 M28 48 V60'}, ARROW_HEAD(76, 54, 1, 0)]},
|
|
188
|
+
'in-transport': {number: '5.8.8.13', name: 'Transport einer Person, aktuell', page: 48, parts: [RAISED, {d: 'M28 54 H76'}, ARROW_HEAD(76, 54, 1, 0)]},
|
|
189
|
+
'transported': {number: '5.8.8.14', name: 'transportiert, Ziel der Bewegung erreicht', page: 48,
|
|
190
|
+
parts: [RAISED, {d: 'M28 54 H76 M78 48 V60'}, ARROW_HEAD(76, 54, 1, 0)]},
|
|
191
|
+
'special-care': {number: '5.8.8.15', name: 'besonders betreuungsbedürftig / unbegleitet / aufsichtspflichtig', page: 48,
|
|
192
|
+
parts: [PERSON, {d: 'M50 8 L38 56 M50 8 L62 56'}]},
|
|
193
|
+
'nursing-care': {number: '5.8.8.16', name: 'pflegebedürftig', page: 48, parts: [PERSON, {d: 'M38 18 V42'}]},
|
|
194
|
+
'reduced-mobility': {number: '5.8.8.17', name: 'mobilitätseingeschränkt', page: 48, parts: [RAISED, {circle: [40, 54, 3]}, {circle: [60, 54, 3]}]},
|
|
195
|
+
|
|
196
|
+
'road-closed': {number: '5.8.9.1', name: 'gesperrt (i. S. v. für Einsatzkräfte befahrbar)', page: 49, parts: [{d: 'M50 6 V54 M38 20 L62 40 M62 20 L38 40'}]},
|
|
197
|
+
'one-way': {number: '5.8.9.2', name: 'Einbahnstraßenregelung', page: 49, parts: [{d: 'M44 6 V54 M56 12 V54 M56 12 L64 26'}]},
|
|
198
|
+
'road-difficult': {number: '5.8.9.3', name: 'schwierig befahrbar / teilblockiert', page: 49, parts: [{d: 'M45 6 V54 M55 6 V54'}]},
|
|
199
|
+
'road-blocked': {number: '5.8.9.4', name: 'nicht befahrbar / blockiert', page: 49, parts: [{d: 'M38 6 V54 M46 6 V54 M54 6 V54 M62 6 V54'}]},
|
|
200
|
+
} as const satisfies Record<string, AdditionalSign>
|
|
201
|
+
|
|
202
|
+
/** The short English name of an additional sign. */
|
|
203
|
+
export type AdditionalSignName = keyof typeof ADDITIONAL_SIGNS
|
|
204
|
+
|
|
205
|
+
/** An additional sign as an SVG tree on the common canvas, its box in the middle at its own size. */
|
|
206
|
+
export function additionalSignTree(name: AdditionalSignName): SvgElement {
|
|
207
|
+
const sign: AdditionalSign = ADDITIONAL_SIGNS[name]
|
|
208
|
+
return canvas([group(sign.parts.map(part => boxPart(part, BLACK)), {transform: 'translate(10 10)'})])
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** An additional sign as SVG markup. */
|
|
212
|
+
export function additionalSign(name: AdditionalSignName): string {
|
|
213
|
+
return renderSvg(additionalSignTree(name))
|
|
214
|
+
}
|
package/src/symbols/catalog.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {ABILITIES, type AbilityName} from './abilities'
|
|
2
|
+
import {ADDITIONAL_SIGNS, additionalSignTree, type AdditionalSignName} from './additional'
|
|
2
3
|
import {tacticalSignTree, type TacticalSignSpec} from './signs'
|
|
3
4
|
import type {SvgElement} from './svg'
|
|
4
5
|
import {markSymbolTree, type MarkKind} from './tactical'
|
|
@@ -19,7 +20,7 @@ export interface CatalogEntry {
|
|
|
19
20
|
name: string
|
|
20
21
|
page?: number
|
|
21
22
|
recommended: boolean
|
|
22
|
-
drawing: {sign: TacticalSignSpec} | {mark: MarkKind}
|
|
23
|
+
drawing: {sign: TacticalSignSpec} | {additional: AdditionalSignName} | {mark: MarkKind}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/** The source the catalogue follows, to be named wherever its signs are shown. */
|
|
@@ -30,23 +31,37 @@ function entry(number: string, name: string, page: number, sign: TacticalSignSpe
|
|
|
30
31
|
return {id, number, name, page, recommended: true, drawing: {sign}}
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/** The additional signs of chapter 5 whose number starts with `section`, as catalogue entries. */
|
|
35
|
+
function additionalEntries(section: string): CatalogEntry[] {
|
|
36
|
+
return Object.entries(ADDITIONAL_SIGNS)
|
|
37
|
+
.filter(([, sign]) => sign.number.startsWith(`${section}.`))
|
|
38
|
+
.map(([name, sign]) => ({id: sign.number, number: sign.number, name: sign.name, page: sign.page, recommended: true,
|
|
39
|
+
drawing: {additional: name as AdditionalSignName}}))
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
function ownMark(number: string, name: string, mark: MarkKind): CatalogEntry {
|
|
34
43
|
return {id: number, number, name, recommended: false, drawing: {mark}}
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
/** The drawing of a catalogue entry as a tree of SVG elements. */
|
|
38
47
|
export function catalogSignTree(entry: CatalogEntry): SvgElement {
|
|
39
|
-
|
|
48
|
+
if ('sign' in entry.drawing) return tacticalSignTree(entry.drawing.sign)
|
|
49
|
+
if ('additional' in entry.drawing) return additionalSignTree(entry.drawing.additional)
|
|
50
|
+
return markSymbolTree(entry.drawing.mark)
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
const FIRE = {organisation: 'fire'} as const
|
|
54
|
+
const COMMAND = {organisation: 'command', supplements: ['command']} as const
|
|
55
|
+
const LEADER = {form: 'person', supplements: ['command']} as const
|
|
43
56
|
|
|
44
57
|
/**
|
|
45
|
-
* The signs of chapters 1 to
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
58
|
+
* The signs of chapters 1 to 6 and annexes C and D of the recommendations, in their order, then the
|
|
59
|
+
* library's own water supply marks. Where a chapter explains a way of writing rather than a sign
|
|
60
|
+
* (5.3, 5.6, 5.8.1.13 before a sign, 6.1, 6.2), its example stands for it. Chapter 1 is drawn black
|
|
61
|
+
* on white as printed, chapter 4 on a plain formation; colours are shown on a tactical formation,
|
|
62
|
+
* supplements, vehicles and sizes in fire service red. Letters that annex C writes inside a symbol
|
|
63
|
+
* ("P", "G", "ATF") stand in field A here, and the flying line of C.1.13 sits under the form as in
|
|
64
|
+
* 5.1.4.
|
|
50
65
|
*/
|
|
51
66
|
export const TACTICAL_SIGN_CATALOG: readonly CatalogEntry[] = [
|
|
52
67
|
entry('1.1', 'Taktische Formation', 14, {form: 'formation'}),
|
|
@@ -102,6 +117,9 @@ export const TACTICAL_SIGN_CATALOG: readonly CatalogEntry[] = [
|
|
|
102
117
|
entry('5.1.4.1', 'Einsatz von Luftfahrzeugen/Fliegen allgemein', 34, {form: 'aircraft', ...FIRE, flight: 'flying'}),
|
|
103
118
|
entry('5.1.4.2', 'Drehflügler/Hubschrauber', 34, {form: 'aircraft', ...FIRE, flight: 'rotary-wing'}),
|
|
104
119
|
entry('5.1.4.3', 'Flächenflügler/Flugzeug', 34, {form: 'aircraft', ...FIRE, flight: 'fixed-wing'}),
|
|
120
|
+
...additionalEntries('5.2'),
|
|
121
|
+
entry('5.3', 'Stärkeangabe, z. B. 1/1/6/40/48 (Gesamtstärke unterstrichen)', 35,
|
|
122
|
+
{form: 'formation', ...FIRE, size: 'association-1', strength: '1/1/6/40/48'}),
|
|
105
123
|
entry('5.4.1', 'Trupp/selbstständiger Trupp', 37, {form: 'formation', ...FIRE, size: 'squad'}),
|
|
106
124
|
entry('5.4.2', 'Staffel', 37, {form: 'formation', ...FIRE, size: 'section'}),
|
|
107
125
|
entry('5.4.3', 'Gruppe', 37, {form: 'formation', ...FIRE, size: 'group'}),
|
|
@@ -109,6 +127,14 @@ export const TACTICAL_SIGN_CATALOG: readonly CatalogEntry[] = [
|
|
|
109
127
|
entry('5.5.1', 'Bereitschaft (Verband I)', 37, {form: 'formation', ...FIRE, size: 'association-1'}),
|
|
110
128
|
entry('5.5.2', 'Abteilung (Verband II)', 37, {form: 'formation', ...FIRE, size: 'association-2'}),
|
|
111
129
|
entry('5.5.3', 'Großverband (Verband III)', 37, {form: 'formation', ...FIRE, size: 'association-3'}),
|
|
130
|
+
entry('5.6', 'Taktische Zeitangabe, z. B. 040835jun23 = 4. Juni 2023, 08:35 Uhr', 38,
|
|
131
|
+
{form: 'formation', ...FIRE, size: 'group', time: '040835jun23'}),
|
|
132
|
+
...additionalEntries('5.7'),
|
|
133
|
+
...additionalEntries('5.8'),
|
|
134
|
+
entry('5.8.1.13', 'Hinweis auf Vermutung, dem Taktischen Zeichen vorangestellt', 42, {form: 'person', certainty: 'presumed'}, '5.8.1.13-before-sign'),
|
|
135
|
+
entry('6.1', 'Ergänzende Angaben in den Feldern A und B, z. B. Strömungsretter der DLRG', 50,
|
|
136
|
+
{form: 'formation', organisation: 'aid', designation: 'Strömungsretter', abilities: ['water-rescue'], fieldB: 'DLRG'}),
|
|
137
|
+
entry('6.2', 'Identifizierung Taktischer Formationen, z. B. 2-1-3', 52, {form: 'formation', ...FIRE, size: 'group', identification: '2-1-3'}),
|
|
112
138
|
entry('C.1.1', 'Löschstaffel (Staffellöschfahrzeug)', 71, {form: 'formation', ...FIRE, size: 'section', abilities: ['firefighting']}),
|
|
113
139
|
entry('C.1.2', 'Löschgruppe (Löschgruppenfahrzeug)', 71, {form: 'formation', ...FIRE, size: 'group', abilities: ['firefighting']}),
|
|
114
140
|
entry('C.1.3', 'Löschzug einer Feuerwehr', 71, {form: 'formation', ...FIRE, size: 'platoon', abilities: ['firefighting']}),
|
|
@@ -155,6 +181,52 @@ export const TACTICAL_SIGN_CATALOG: readonly CatalogEntry[] = [
|
|
|
155
181
|
entry('C.2.29', 'Tragkraftspritzenanhänger', 76, {form: 'land-vehicle', ...FIRE, body: 'trailer', drive: 'towed-by-car', abilities: ['firefighting']}),
|
|
156
182
|
entry('C.2.30', 'Feuerwehr Netzersatzanlage 120 kVA', 76, {form: 'land-vehicle', ...FIRE, body: 'trailer', drive: 'towed-by-car', supplements: ['logistics'], abilities: ['power'], designation: '120'}),
|
|
157
183
|
entry('C.2.31', 'Geschützte Löschdrohne/Löschroboter auf Kettenfahrgestell', 76, {form: 'land-vehicle', ...FIRE, protected: true, drive: 'tracked', supplements: ['uncrewed'], abilities: ['firefighting']}),
|
|
184
|
+
entry('D.1.1', 'Befehlsstelle, Führungsstelle (aktiv im Einsatz), mit Linie zum Standort', 76,
|
|
185
|
+
{form: 'formation', ...COMMAND, designation: 'Bezeichnung', located: true}),
|
|
186
|
+
entry('D.1.2', 'Katastrophenschutzleitung im Einsatz', 76, {form: 'formation', ...COMMAND, text: 'KatSL'}),
|
|
187
|
+
entry('D.1.3', 'Technische Einsatzleitung „Evakuierung“ im Einsatz', 76, {form: 'formation', ...COMMAND, text: 'TEL', subtitle: 'Evakuierung'}),
|
|
188
|
+
entry('D.1.4', 'Einsatzleitung im Einsatz', 76, {form: 'formation', ...COMMAND, text: 'EL'}),
|
|
189
|
+
entry('D.1.5', 'Einsatzabschnittsleitung „Nord“ im Einsatz', 77, {form: 'formation', ...COMMAND, text: 'EAL', subtitle: 'Nord'}),
|
|
190
|
+
entry('D.1.6', 'Untereinsatzabschnittsleitung im Einsatz', 77, {form: 'formation', ...COMMAND, text: 'UEAL'}),
|
|
191
|
+
entry('D.1.7', 'Führungsgruppe TEL i. S. einer Stabsstelle', 77, {form: 'formation', ...COMMAND, size: 'group', text: 'TEL'}),
|
|
192
|
+
entry('D.1.8', 'Führungsgruppe einer Feuerwehrbereitschaft', 77, {form: 'formation', ...FIRE, supplements: ['command'], size: 'group', text: 'Ber'}),
|
|
193
|
+
entry('D.1.9', 'Zugtrupp einer Sanitätseinheit', 77, {form: 'formation', organisation: 'aid', supplements: ['command'], size: 'squad', abilities: ['medical']}),
|
|
194
|
+
entry('D.2.1', 'Bereitstellungsraum', 77, {form: 'place', organisation: 'command', figure: 'staging-area'}),
|
|
195
|
+
entry('D.2.2', 'Bereitstellungsraum mit Meldekopf', 77, {form: 'place', organisation: 'command', figure: 'staging-area-with-report'}),
|
|
196
|
+
entry('D.2.3', 'Meldekopf', 77, {form: 'place', organisation: 'command', text: 'M'}),
|
|
197
|
+
entry('D.2.4', 'Lotsenstelle/Abholpunkt', 77, {form: 'place', organisation: 'command', text: 'L'}),
|
|
198
|
+
entry('D.2.5', 'Leitstelle', 78, {form: 'place', organisation: 'command', supplements: ['roof', 'command'], text: 'LtS'}),
|
|
199
|
+
entry('D.2.6', 'Hubschrauberlandezone/Übergabepunkt Luft-Boden', 78, {form: 'place', organisation: 'command', figure: 'landing-zone'}),
|
|
200
|
+
entry('D.2.7', 'Hubschrauberlandeplatz, gesicherte Infrastruktur/für Notfälle vorbereitet (auch temporär)', 78,
|
|
201
|
+
{form: 'place', organisation: 'command', supplements: ['roof'], figure: 'landing-zone'}),
|
|
202
|
+
entry('D.3.1', 'Leiter der Technischen Einsatzleitung des Landkreises Ahrweiler', 78,
|
|
203
|
+
{...LEADER, organisation: 'command', level: 2, text: 'TEL', fieldB: 'AW'}),
|
|
204
|
+
entry('D.3.2', 'Einsatzleiter', 78, {...LEADER, organisation: 'command', text: 'EL'}),
|
|
205
|
+
entry('D.3.3', 'Leitender Notarzt', 78, {...LEADER, organisation: 'command', level: 2, text: 'LNA'}),
|
|
206
|
+
entry('D.3.4', 'Organisatorischer Leiter', 78, {...LEADER, organisation: 'command', level: 2, text: 'OrgL'}),
|
|
207
|
+
entry('D.3.5', 'Einsatzabschnittsleiter', 78, {...LEADER, organisation: 'command', text: 'EAL'}),
|
|
208
|
+
entry('D.3.6', 'Untereinsatzabschnittsleiter', 78, {...LEADER, organisation: 'command', text: 'UEAL'}),
|
|
209
|
+
entry('D.3.7', 'Zugführer eines Löschzuges der Feuerwehr', 78, {...LEADER, ...FIRE, size: 'platoon', abilities: ['firefighting']}),
|
|
210
|
+
entry('D.3.8', 'Zugführer eines Technischen Zuges des THW', 79, {...LEADER, organisation: 'thw', size: 'platoon', text: 'TZ'}),
|
|
211
|
+
entry('D.3.9', 'Zugführer eines Sanitätszuges des Arbeiter-Samariter-Bundes', 79,
|
|
212
|
+
{...LEADER, organisation: 'aid', size: 'platoon', abilities: ['medical'], fieldB: 'ASB'}),
|
|
213
|
+
entry('D.3.10', 'Zugführer einer Einsatzeinheit des Deutschen Roten Kreuzes', 79,
|
|
214
|
+
{...LEADER, organisation: 'aid', size: 'platoon', abilities: ['care', 'medical'], fieldB: 'DRK'}),
|
|
215
|
+
entry('D.3.11', 'Zugführer eines Betreuungszuges des Arbeiter-Samariter-Bundes', 79,
|
|
216
|
+
{...LEADER, organisation: 'aid', size: 'platoon', abilities: ['care'], fieldB: 'ASB'}),
|
|
217
|
+
entry('D.3.12', 'Gruppenführer einer Betreuungsgruppe des Malteser Hilfsdienstes', 79,
|
|
218
|
+
{...LEADER, organisation: 'aid', size: 'group', abilities: ['care'], fieldB: 'MHD'}),
|
|
219
|
+
entry('D.3.13', 'Gruppenführer einer Schnell-Einsatz-Gruppe der Johanniter-Unfall-Hilfe', 79,
|
|
220
|
+
{...LEADER, organisation: 'aid', size: 'group', text: 'SEG', fieldB: 'JUH'}),
|
|
221
|
+
entry('D.3.14', 'Fachberater des THW, in Hauptfunktion stellvertretender Ortsbeauftragter', 79,
|
|
222
|
+
{form: 'person', organisation: 'thw', supplements: ['special-function'], text: 'THW', fieldB: 'stv OB'}),
|
|
223
|
+
entry('D.3.15', 'Rotkreuzbeauftragter', 79, {form: 'person', organisation: 'aid', supplements: ['special-function'], text: 'RKB', fieldB: 'DRK'}),
|
|
224
|
+
entry('D.4.1', 'Leiter der Kreisleitstelle des Kreises Steinfurt', 80, {...LEADER, organisation: 'command', level: 2, text: 'LtS', fieldB: 'ST'}),
|
|
225
|
+
entry('D.4.2', 'Kreisbrandmeister des Kreises Mettmann', 80, {...LEADER, ...FIRE, level: 2, text: 'KBM', fieldB: 'ME'}),
|
|
226
|
+
entry('D.4.3', 'Leiter der Gefahrenabwehr in der kreisfreien Stadt Mönchengladbach', 80,
|
|
227
|
+
{...LEADER, organisation: 'command', level: 2, text: 'LtrGA', fieldB: 'MG'}),
|
|
228
|
+
entry('D.4.4', 'Leiter der Gefahrenabwehrkräfte der Bundespolizei', 80, {...LEADER, organisation: 'police', level: 5, fieldB: 'BuPol'}),
|
|
229
|
+
entry('D.4.5', 'Leiter (Koordinator) einer internationalen Hilfsaktion', 80, {...LEADER, organisation: 'command', level: 6}),
|
|
158
230
|
ownMark('W.1', 'Unterflurhydrant', 'hydrant-underground'),
|
|
159
231
|
ownMark('W.2', 'Überflurhydrant', 'hydrant-pillar'),
|
|
160
232
|
ownMark('W.3', 'Offenes Gewässer', 'open-water'),
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The marking of dangerous goods after ADR 2025: the danger labels of 5.2.2.2.2, the
|
|
3
|
+
* environmentally hazardous substance mark of 5.2.1.8.3 and the orange-coloured plate of 5.3.2.2.
|
|
4
|
+
* The pictograms follow the descriptions and proportions of the ADR without copying its artwork.
|
|
5
|
+
*
|
|
6
|
+
* A label is drawn on its own 100 × 100 canvas spanning the diagonal of the square on its point, so
|
|
7
|
+
* the 100 mm side of 5.2.2.2.1.1.2 is about 71 units and one unit about 1.4 mm. The line runs 5
|
|
8
|
+
* units inside the corners, about 5 mm inside the edge; the symbol sits in the upper half inside
|
|
9
|
+
* that line and the class in the lower corner. The ADR names no colour values; the label colours
|
|
10
|
+
* are the usual print tones, and the orange of the plate lies inside the chromaticity range of the
|
|
11
|
+
* note to 5.3.2.2.1. Where the ADR allows a black or a white symbol, the black one is drawn.
|
|
12
|
+
* The pages of the ADR excerpt the patterns are printed on are given, to check the drawings.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import {BLACK, WHITE, element, group, label, renderSvg, round, type SvgElement} from './svg'
|
|
16
|
+
|
|
17
|
+
const LABEL_RED = '#E30613'
|
|
18
|
+
const LABEL_GREEN = '#009A44'
|
|
19
|
+
const LABEL_BLUE = '#0079C1'
|
|
20
|
+
const LABEL_YELLOW = '#FFD500'
|
|
21
|
+
const LABEL_ORANGE = '#F39200'
|
|
22
|
+
const PLATE_ORANGE = '#FF7F00'
|
|
23
|
+
|
|
24
|
+
/** The pictogram in the upper half of a label (and the batteries of 9A in the lower half). */
|
|
25
|
+
type LabelSymbol = 'bomb' | 'division' | 'flame' | 'cylinder' | 'skull' | 'flame-over-circle' | 'biohazard' | 'trefoil'
|
|
26
|
+
| 'fissile' | 'corrosion' | 'batteries'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* How the background of a label is laid out: one colour, two halves, seven red stripes over the
|
|
30
|
+
* whole label (4.1) or seven black ones in its upper half (9, 9A), or a white label whose upper or
|
|
31
|
+
* lower half is coloured inside a white rim (7B, 7C, 8).
|
|
32
|
+
*/
|
|
33
|
+
type LabelGround =
|
|
34
|
+
| {plain: string}
|
|
35
|
+
| {upper: string, lower: string}
|
|
36
|
+
| {stripes: string}
|
|
37
|
+
| {upperStripes: string}
|
|
38
|
+
| {rimmedUpper: string}
|
|
39
|
+
| {rimmedLower: string}
|
|
40
|
+
|
|
41
|
+
/** The pattern numbers of 5.2.2.2.2 in the order of the ADR; iterate these, since a record puts whole-number keys first. */
|
|
42
|
+
export const DANGER_LABEL_PATTERNS = [
|
|
43
|
+
'1', '1.4', '1.5', '1.6', '2.1', '2.2', '2.3', '3', '4.1', '4.2', '4.3', '5.1', '5.2', '6.1', '6.2', '7A', '7B', '7C', '7E', '8', '9', '9A',
|
|
44
|
+
] as const
|
|
45
|
+
|
|
46
|
+
/** A danger label pattern number. */
|
|
47
|
+
export type DangerLabelPattern = typeof DANGER_LABEL_PATTERNS[number]
|
|
48
|
+
|
|
49
|
+
/** A danger label pattern of 5.2.2.2.2. */
|
|
50
|
+
export interface DangerLabel {
|
|
51
|
+
pattern: DangerLabelPattern
|
|
52
|
+
/** The class the label stands for. */
|
|
53
|
+
hazardClass: string
|
|
54
|
+
/** The meaning after the ADR, in German. */
|
|
55
|
+
name: string
|
|
56
|
+
/** The page of the ADR 2025 excerpt of chapter 5.2 the pattern is printed on. */
|
|
57
|
+
page: string
|
|
58
|
+
ground: LabelGround
|
|
59
|
+
symbols: readonly LabelSymbol[]
|
|
60
|
+
/** The figure in the lower corner. */
|
|
61
|
+
figure: string
|
|
62
|
+
/** The placeholders of class 1 for division and compatibility group. */
|
|
63
|
+
placeholders?: string
|
|
64
|
+
/** For class 7 categories I to III: "RADIOACTIVE" followed by this many red bars. */
|
|
65
|
+
radioactiveBars?: number
|
|
66
|
+
figureColour?: string
|
|
67
|
+
underlined?: boolean
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The danger label patterns of 5.2.2.2.2, keyed by their pattern number. */
|
|
71
|
+
export const DANGER_LABELS: Readonly<Record<DangerLabelPattern, DangerLabel>> = {
|
|
72
|
+
'1': {pattern: '1', hazardClass: '1', name: 'Explosive Stoffe und Gegenstände mit Explosivstoff (Unterklassen 1.1, 1.2, 1.3)', page: '5.2-10',
|
|
73
|
+
ground: {plain: LABEL_ORANGE}, symbols: ['bomb'], figure: '1', placeholders: '** *'},
|
|
74
|
+
'1.4': {pattern: '1.4', hazardClass: '1', name: 'Explosive Stoffe und Gegenstände mit Explosivstoff (Unterklasse 1.4)', page: '5.2-10',
|
|
75
|
+
ground: {plain: LABEL_ORANGE}, symbols: ['division'], figure: '1', placeholders: '*'},
|
|
76
|
+
'1.5': {pattern: '1.5', hazardClass: '1', name: 'Explosive Stoffe und Gegenstände mit Explosivstoff (Unterklasse 1.5)', page: '5.2-10',
|
|
77
|
+
ground: {plain: LABEL_ORANGE}, symbols: ['division'], figure: '1', placeholders: '*'},
|
|
78
|
+
'1.6': {pattern: '1.6', hazardClass: '1', name: 'Explosive Stoffe und Gegenstände mit Explosivstoff (Unterklasse 1.6)', page: '5.2-10',
|
|
79
|
+
ground: {plain: LABEL_ORANGE}, symbols: ['division'], figure: '1', placeholders: '*'},
|
|
80
|
+
'2.1': {pattern: '2.1', hazardClass: '2', name: 'Entzündbare Gase', page: '5.2-11', ground: {plain: LABEL_RED}, symbols: ['flame'], figure: '2'},
|
|
81
|
+
'2.2': {pattern: '2.2', hazardClass: '2', name: 'Nicht entzündbare, nicht giftige Gase', page: '5.2-11', ground: {plain: LABEL_GREEN},
|
|
82
|
+
symbols: ['cylinder'], figure: '2'},
|
|
83
|
+
'2.3': {pattern: '2.3', hazardClass: '2', name: 'Giftige Gase', page: '5.2-11', ground: {plain: WHITE}, symbols: ['skull'], figure: '2'},
|
|
84
|
+
'3': {pattern: '3', hazardClass: '3', name: 'Entzündbare flüssige Stoffe', page: '5.2-11', ground: {plain: LABEL_RED}, symbols: ['flame'], figure: '3'},
|
|
85
|
+
'4.1': {pattern: '4.1', hazardClass: '4.1',
|
|
86
|
+
name: 'Entzündbare feste Stoffe, selbstzersetzliche Stoffe, polymerisierende Stoffe und desensibilisierte explosive feste Stoffe',
|
|
87
|
+
page: '5.2-12', ground: {stripes: LABEL_RED}, symbols: ['flame'], figure: '4'},
|
|
88
|
+
'4.2': {pattern: '4.2', hazardClass: '4.2', name: 'Selbstentzündliche Stoffe', page: '5.2-12', ground: {upper: WHITE, lower: LABEL_RED},
|
|
89
|
+
symbols: ['flame'], figure: '4'},
|
|
90
|
+
'4.3': {pattern: '4.3', hazardClass: '4.3', name: 'Stoffe, die in Berührung mit Wasser entzündbare Gase entwickeln', page: '5.2-12',
|
|
91
|
+
ground: {plain: LABEL_BLUE}, symbols: ['flame'], figure: '4'},
|
|
92
|
+
'5.1': {pattern: '5.1', hazardClass: '5.1', name: 'Entzündend (oxidierend) wirkende Stoffe', page: '5.2-13', ground: {plain: LABEL_YELLOW},
|
|
93
|
+
symbols: ['flame-over-circle'], figure: '5.1'},
|
|
94
|
+
'5.2': {pattern: '5.2', hazardClass: '5.2', name: 'Organische Peroxide', page: '5.2-13', ground: {upper: LABEL_RED, lower: LABEL_YELLOW},
|
|
95
|
+
symbols: ['flame'], figure: '5.2'},
|
|
96
|
+
'6.1': {pattern: '6.1', hazardClass: '6.1', name: 'Giftige Stoffe', page: '5.2-13', ground: {plain: WHITE}, symbols: ['skull'], figure: '6'},
|
|
97
|
+
'6.2': {pattern: '6.2', hazardClass: '6.2', name: 'Ansteckungsgefährliche Stoffe', page: '5.2-13', ground: {plain: WHITE}, symbols: ['biohazard'], figure: '6'},
|
|
98
|
+
'7A': {pattern: '7A', hazardClass: '7', name: 'Radioaktive Stoffe, Kategorie I – WEISS', page: '5.2-14', ground: {plain: WHITE}, symbols: ['trefoil'],
|
|
99
|
+
figure: '7', radioactiveBars: 1},
|
|
100
|
+
'7B': {pattern: '7B', hazardClass: '7', name: 'Radioaktive Stoffe, Kategorie II – GELB', page: '5.2-14', ground: {rimmedUpper: LABEL_YELLOW},
|
|
101
|
+
symbols: ['trefoil'], figure: '7', radioactiveBars: 2},
|
|
102
|
+
'7C': {pattern: '7C', hazardClass: '7', name: 'Radioaktive Stoffe, Kategorie III – GELB', page: '5.2-14', ground: {rimmedUpper: LABEL_YELLOW},
|
|
103
|
+
symbols: ['trefoil'], figure: '7', radioactiveBars: 3},
|
|
104
|
+
'7E': {pattern: '7E', hazardClass: '7', name: 'Radioaktive Stoffe, spaltbar', page: '5.2-14', ground: {plain: WHITE}, symbols: ['fissile'], figure: '7'},
|
|
105
|
+
'8': {pattern: '8', hazardClass: '8', name: 'Ätzende Stoffe', page: '5.2-15', ground: {rimmedLower: BLACK}, symbols: ['corrosion'], figure: '8',
|
|
106
|
+
figureColour: WHITE},
|
|
107
|
+
'9': {pattern: '9', hazardClass: '9', name: 'Verschiedene gefährliche Stoffe und Gegenstände', page: '5.2-15', ground: {upperStripes: BLACK},
|
|
108
|
+
symbols: [], figure: '9', underlined: true},
|
|
109
|
+
'9A': {pattern: '9A', hazardClass: '9', name: 'Verschiedene gefährliche Stoffe und Gegenstände (Lithiumbatterien)', page: '5.2-15',
|
|
110
|
+
ground: {upperStripes: BLACK}, symbols: ['batteries'], figure: '9', underlined: true},
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const DIAMOND = 'M50 0 L100 50 L50 100 L0 50 Z'
|
|
114
|
+
const UPPER_HALF = 'M0 50 L50 0 L100 50 Z'
|
|
115
|
+
const LOWER_HALF = 'M0 50 L50 100 L100 50 Z'
|
|
116
|
+
/** How far the line runs inside the corners. */
|
|
117
|
+
const INSET = 5
|
|
118
|
+
|
|
119
|
+
/** How far the label reaches above and below its middle line at `x`. */
|
|
120
|
+
function halfHeight(x: number): number {
|
|
121
|
+
return 50 - Math.abs(x - 50)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A vertical stripe from `x0` to `x1` cut to the label, through the lower half too when `lowerToo`, else down to the middle line. */
|
|
125
|
+
function stripe(x0: number, x1: number, lowerToo: boolean): string {
|
|
126
|
+
const apex = x0 < 50 && x1 > 50
|
|
127
|
+
const top = [[x0, 50 - halfHeight(x0)], ...(apex ? [[50, 0]] : []), [x1, 50 - halfHeight(x1)]]
|
|
128
|
+
const bottom = lowerToo
|
|
129
|
+
? [[x1, 50 + halfHeight(x1)], ...(apex ? [[50, 100]] : []), [x0, 50 + halfHeight(x0)]]
|
|
130
|
+
: [[x1, 50], [x0, 50]]
|
|
131
|
+
return `M${[...top, ...bottom].map(([x, y]) => `${round(x!)} ${round(y!)}`).join(' L')} Z`
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Seven stripes across the label. */
|
|
135
|
+
function stripes(colour: string, lowerToo: boolean): SvgElement {
|
|
136
|
+
const width = 100 / 15
|
|
137
|
+
const d = Array.from({length: 7}, (_, index) => stripe(width * (2 * index + 1), width * (2 * index + 2), lowerToo)).join(' ')
|
|
138
|
+
return element('path', {d, fill: colour})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A circle as a path, for shapes cut with the even-odd rule. */
|
|
142
|
+
function circlePath(cx: number, cy: number, r: number): string {
|
|
143
|
+
return `M${round(cx - r)} ${round(cy)} a${r} ${r} 0 1 0 ${2 * r} 0 a${r} ${r} 0 1 0 ${-2 * r} 0 Z`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const FLAME = 'M50 12 C57 19 61 25 59 32 C58 37 54 40 50 40 C45 40 41 36 42 31 C42 27 45 25 46 21 C48 24 50 25 51 22 C52 19 51 16 50 12 Z'
|
|
147
|
+
|
|
148
|
+
/** The three crescents of the biohazard sign around (50, 30), each a ring open to the outside. */
|
|
149
|
+
function biohazard(ink: string): SvgElement[] {
|
|
150
|
+
const crescents = [-90, 30, 150].map(angle => {
|
|
151
|
+
const a = angle * Math.PI / 180
|
|
152
|
+
const at = (distance: number) => [50 + distance * Math.cos(a), 30 + distance * Math.sin(a)] as const
|
|
153
|
+
const [ox, oy] = at(7)
|
|
154
|
+
const [ix, iy] = at(9.5)
|
|
155
|
+
return `${circlePath(ox, oy, 8)} ${circlePath(ix, iy, 6)}`
|
|
156
|
+
})
|
|
157
|
+
return [
|
|
158
|
+
...crescents.map(d => element('path', {d, fill: ink, 'fill-rule': 'evenodd'})),
|
|
159
|
+
element('circle', {cx: 50, cy: 30, r: 5, fill: 'none', stroke: ink, 'stroke-width': 1.5}),
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** The pictogram of a label, inside the line around the label. */
|
|
164
|
+
function symbol(kind: LabelSymbol, ink: string): SvgElement[] {
|
|
165
|
+
const fill = (d: string) => element('path', {d, fill: ink})
|
|
166
|
+
const stroke = (d: string, width = 2.5) => element('path', {d, fill: 'none', stroke: ink, 'stroke-width': width, 'stroke-linecap': 'round'})
|
|
167
|
+
switch (kind) {
|
|
168
|
+
case 'bomb': return [
|
|
169
|
+
element('circle', {cx: 46, cy: 34, r: 8, fill: ink}),
|
|
170
|
+
fill('M53 28 L55 19 L58 24 L60 18 L62 25 L66 24 L64 29 L70 32 L62 32 Z'),
|
|
171
|
+
fill('M32 30 L35 28 L35 32 Z M38 21 L41 22 L39 24 Z M36 44 L39 43 L38 46 Z'),
|
|
172
|
+
]
|
|
173
|
+
case 'division': return []
|
|
174
|
+
case 'flame': return [fill(FLAME), stroke('M38 44 H62', 2)]
|
|
175
|
+
case 'cylinder': return [fill('M36 42 L56 22 A4 4 0 0 1 61.7 27.7 L41.7 47.7 A4 4 0 0 1 36 42 Z'), stroke('M59 24 L62 21 M60 19 L64 23', 2)]
|
|
176
|
+
case 'skull': return [
|
|
177
|
+
fill('M42 26 A8 8 0 1 1 58 26 C58 30 56 31 55 32 V35 H45 V32 C44 31 42 30 42 26 Z'),
|
|
178
|
+
element('circle', {cx: 47, cy: 26, r: 2, fill: WHITE}),
|
|
179
|
+
element('circle', {cx: 53, cy: 26, r: 2, fill: WHITE}),
|
|
180
|
+
stroke('M37 36 L63 46 M63 36 L37 46', 3),
|
|
181
|
+
]
|
|
182
|
+
case 'flame-over-circle': return [fill('M50 10 C55 15 58 19 57 24 C56 28 53 30 50 30 C46 30 43 27 44 23 C44 20 46 18 47 15 C48 17 50 18 51 16 Z'),
|
|
183
|
+
element('circle', {cx: 50, cy: 37, r: 6, fill: 'none', stroke: ink, 'stroke-width': 3}), stroke('M38 46 H62', 2)]
|
|
184
|
+
case 'biohazard': return biohazard(ink)
|
|
185
|
+
case 'trefoil': return [
|
|
186
|
+
fill('M50 28 L56 17.6 A12 12 0 0 0 44 17.6 Z M50 28 L62 28 A12 12 0 0 1 56 38.4 Z M50 28 L44 38.4 A12 12 0 0 1 38 28 Z'),
|
|
187
|
+
element('circle', {cx: 50, cy: 28, r: 2.5, fill: ink}),
|
|
188
|
+
]
|
|
189
|
+
case 'fissile': return [
|
|
190
|
+
label('FISSILE', 50, 32, ink, 30, 10),
|
|
191
|
+
element('rect', {x: 34, y: 52, width: 32, height: 14, fill: 'none', stroke: ink, 'stroke-width': 1}),
|
|
192
|
+
label('CRITICALITY SAFETY INDEX', 50, 56, ink, 29, 3.5),
|
|
193
|
+
]
|
|
194
|
+
case 'corrosion': return [
|
|
195
|
+
fill('M40 17 L44 15 L49 25 L45 27 Z M56 15 L60 17 L55 27 L51 25 Z'),
|
|
196
|
+
stroke('M45 30 V32 M55 30 V32 M45 35 V36 M55 35 V36', 1.5),
|
|
197
|
+
fill('M34 40 H47 V45 H34 Z'),
|
|
198
|
+
stroke('M35 40 V35 M38 40 V34 M41 40 V34 M44 40 V35 M47 42 L50 39', 1.8),
|
|
199
|
+
fill('M53 39 H57 Q59.5 43 62 39 H66 V45 H53 Z'),
|
|
200
|
+
]
|
|
201
|
+
case 'batteries': return [
|
|
202
|
+
element('rect', {x: 38, y: 56, width: 7, height: 12, fill: ink}),
|
|
203
|
+
element('rect', {x: 47, y: 56, width: 7, height: 12, fill: ink}),
|
|
204
|
+
element('rect', {x: 40, y: 54, width: 3, height: 2, fill: ink}),
|
|
205
|
+
element('rect', {x: 49, y: 54, width: 3, height: 2, fill: ink}),
|
|
206
|
+
fill('M57 68 L60 58 L64 62 L63 54 L67 60 L66 68 Z'),
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The ground of a label: its fill, halves or stripes. */
|
|
212
|
+
function ground(layout: LabelGround): SvgElement[] {
|
|
213
|
+
if ('plain' in layout) return [element('path', {d: DIAMOND, fill: layout.plain})]
|
|
214
|
+
if ('upper' in layout) return [element('path', {d: UPPER_HALF, fill: layout.upper}), element('path', {d: LOWER_HALF, fill: layout.lower})]
|
|
215
|
+
if ('stripes' in layout) return [element('path', {d: DIAMOND, fill: WHITE}), stripes(layout.stripes, true)]
|
|
216
|
+
if ('upperStripes' in layout) return [element('path', {d: DIAMOND, fill: WHITE}), stripes(layout.upperStripes, false)]
|
|
217
|
+
const rim = 'rimmedUpper' in layout
|
|
218
|
+
? {d: `M${INSET} 50 L50 ${INSET} L${100 - INSET} 50 Z`, fill: layout.rimmedUpper}
|
|
219
|
+
: {d: `M${INSET} 50 L50 ${100 - INSET} L${100 - INSET} 50 Z`, fill: layout.rimmedLower}
|
|
220
|
+
return [element('path', {d: DIAMOND, fill: WHITE}), element('path', rim)]
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The line about 5 mm inside the edge. */
|
|
224
|
+
function innerLine(): SvgElement {
|
|
225
|
+
return element('path', {d: `M50 ${INSET} L${100 - INSET} 50 L50 ${100 - INSET} L${INSET} 50 Z`, fill: 'none', stroke: BLACK, 'stroke-width': 1.5,
|
|
226
|
+
'stroke-linejoin': 'round'})
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A danger label as an SVG tree on its 100 × 100 canvas: the ground and line, then the pictogram
|
|
231
|
+
* and writing in a group of their own, then the class figure and a thin edge for white labels.
|
|
232
|
+
*/
|
|
233
|
+
export function dangerLabelTree(pattern: DangerLabelPattern): SvgElement {
|
|
234
|
+
const sign = DANGER_LABELS[pattern]
|
|
235
|
+
const marks: SvgElement[] = sign.symbols.flatMap(kind => symbol(kind, BLACK))
|
|
236
|
+
if (sign.symbols.includes('division')) marks.push(label(sign.pattern, 50, 32, BLACK, 30, 20))
|
|
237
|
+
if (sign.placeholders) marks.push(label(sign.placeholders, 50, 58, BLACK, 30, 9))
|
|
238
|
+
if (sign.radioactiveBars) {
|
|
239
|
+
marks.push(label('RADIOACTIVE', 44, 56, BLACK, 34, 6.5))
|
|
240
|
+
for (let index = 0; index < sign.radioactiveBars; index++) {
|
|
241
|
+
marks.push(element('rect', {x: 64 + index * 3, y: 52, width: 1.8, height: 8, fill: LABEL_RED}))
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const figure = label(sign.figure, 50, 76, sign.figureColour ?? BLACK, 16, 12)
|
|
245
|
+
if (sign.underlined) figure.attributes['text-decoration'] = 'underline'
|
|
246
|
+
return labelCanvas([
|
|
247
|
+
...ground(sign.ground), innerLine(), group(marks), figure,
|
|
248
|
+
element('path', {d: DIAMOND, fill: 'none', stroke: '#808080', 'stroke-width': 0.5}),
|
|
249
|
+
])
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** A danger label as SVG markup. */
|
|
253
|
+
export function dangerLabel(pattern: DangerLabelPattern): string {
|
|
254
|
+
return renderSvg(dangerLabelTree(pattern))
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function labelCanvas(children: SvgElement[]): SvgElement {
|
|
258
|
+
return {tag: 'svg', attributes: {xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 100 100', width: 100, height: 100}, children: [group(children)]}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The mark for environmentally hazardous substances of 5.2.1.8.3: a dead tree and a dead fish, black on a white diamond with a border of 2 mm. */
|
|
262
|
+
export function environmentMarkTree(): SvgElement {
|
|
263
|
+
const stroke = {fill: 'none', stroke: BLACK, 'stroke-width': 2.5, 'stroke-linecap': 'round', 'stroke-linejoin': 'round'}
|
|
264
|
+
return labelCanvas([
|
|
265
|
+
element('path', {d: 'M50 1.5 L98.5 50 L50 98.5 L1.5 50 Z', fill: WHITE, stroke: BLACK, 'stroke-width': 3}),
|
|
266
|
+
element('path', {d: 'M40 58 V28 M40 40 L32 32 M40 34 L48 26 M40 46 L48 40 M32 32 L28 34 M48 26 L52 24', ...stroke}),
|
|
267
|
+
element('path', {d: 'M22 58 H62', ...stroke}),
|
|
268
|
+
element('path', {d: 'M48 70 Q58 62 70 68 Q58 76 48 70 Z M48 70 L42 65 V75 Z', fill: BLACK}),
|
|
269
|
+
element('path', {d: 'M63 66 L66 69 M66 66 L63 69', stroke: WHITE, 'stroke-width': 1}),
|
|
270
|
+
])
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The environment mark as SVG markup. */
|
|
274
|
+
export function environmentMark(): string {
|
|
275
|
+
return renderSvg(environmentMarkTree())
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* A hazard identification number of 5.3.2.3: two or three figures, the first 2 to 9, possibly led by
|
|
280
|
+
* an X; for class 1 the classification code (5.3.2.3.1), such as "1.1D" or "1.4S".
|
|
281
|
+
*/
|
|
282
|
+
export const HAZARD_NUMBER = /^(X?[2-9][0-9]{1,2}|1\.[1-6][A-HJKLNS])$/
|
|
283
|
+
|
|
284
|
+
/** A UN number: four figures. */
|
|
285
|
+
export const UN_NUMBER = /^[0-9]{4}$/
|
|
286
|
+
|
|
287
|
+
/** What an orange-coloured plate carries: nothing, or the hazard identification number over the UN number. */
|
|
288
|
+
export interface WarningPanel {
|
|
289
|
+
hazardNumber?: string
|
|
290
|
+
unNumber?: string
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The orange-coloured plate of 5.3.2.2 on a canvas of 400 × 300 units, one per millimetre: a black
|
|
295
|
+
* border of 15, and with numbers a dividing line of 15 across the middle, the hazard identification
|
|
296
|
+
* number above it and the UN number below in figures 100 high. A plate without numbers has neither.
|
|
297
|
+
* Both numbers are required together and must have the form of the ADR, so a learning card cannot
|
|
298
|
+
* show an impossible plate; the reduced plate with a UN number only (packaged radioactive material
|
|
299
|
+
* under exclusive use, 5.3.2.2.1) is left out on purpose.
|
|
300
|
+
*/
|
|
301
|
+
export function warningPanelTree(panel: WarningPanel = {}): SvgElement {
|
|
302
|
+
const numbered = panel.hazardNumber !== undefined || panel.unNumber !== undefined
|
|
303
|
+
if (numbered && !(panel.hazardNumber && HAZARD_NUMBER.test(panel.hazardNumber) && panel.unNumber && UN_NUMBER.test(panel.unNumber))) {
|
|
304
|
+
throw new Error(`Not a hazard number over a UN number: ${panel.hazardNumber ?? '–'} / ${panel.unNumber ?? '–'}`)
|
|
305
|
+
}
|
|
306
|
+
const parts: SvgElement[] = [element('rect', {x: 7.5, y: 7.5, width: 385, height: 285, fill: PLATE_ORANGE, stroke: BLACK, 'stroke-width': 15})]
|
|
307
|
+
if (numbered) {
|
|
308
|
+
parts.push(
|
|
309
|
+
element('path', {d: 'M7.5 150 H392.5', stroke: BLACK, 'stroke-width': 15}),
|
|
310
|
+
label(panel.hazardNumber!, 200, 80, BLACK, 340, 136),
|
|
311
|
+
label(panel.unNumber!, 200, 222, BLACK, 340, 136),
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
return {tag: 'svg', attributes: {xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 400 300', width: 120, height: 90}, children: [group(parts)]}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** The orange-coloured plate as SVG markup. */
|
|
318
|
+
export function warningPanel(panel: WarningPanel = {}): string {
|
|
319
|
+
return renderSvg(warningPanelTree(panel))
|
|
320
|
+
}
|
package/src/symbols/signs.ts
CHANGED
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
* light background, as on paper: size marks, frames and wheels are black, so a page in dark mode
|
|
12
12
|
* shows them on a light backdrop.
|
|
13
13
|
*
|
|
14
|
-
* Every sign is drawn on the 120 × 80 canvas of the library
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Every sign is drawn on the 120 × 80 canvas of the library, which widens only for writing around
|
|
15
|
+
* the sign (a time, a presumption, an identification, a strength, stars above a size mark, the line
|
|
16
|
+
* to a location); the sign itself keeps its place. Size marks, roofs and supplements are placed
|
|
17
|
+
* relative to the form they belong to, so they fit every basic form; under a roof the size marks sit
|
|
18
|
+
* inside the roof, since the canvas has no room above it.
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
|
-
import {ABILITIES, type Ability, type AbilityName
|
|
20
|
-
import {SIGN_FONT, canvas, element, group, label, renderSvg, type SvgElement} from './svg'
|
|
21
|
+
import {ABILITIES, type Ability, type AbilityName} from './abilities'
|
|
22
|
+
import {BLACK, BOX_STROKE, HAZARD_RED, MEASURE_BLUE, SIGN_FONT, SYMBOL_HEIGHT, SYMBOL_WIDTH, WHITE, asterisk, boxPart, canvas, element, group, label, renderSvg, round, starOffsets, type BoxPart, type SvgElement} from './svg'
|
|
21
23
|
|
|
22
24
|
/** The basic forms of chapter 1, in its order. */
|
|
23
25
|
export const BASIC_FORMS = [
|
|
@@ -86,6 +88,26 @@ export interface TacticalSignSpec {
|
|
|
86
88
|
abilities?: readonly AbilityName[]
|
|
87
89
|
/** A short designation in the upper left corner (field A), such as "ELW 1", as annex C shows it. */
|
|
88
90
|
designation?: string
|
|
91
|
+
/** A second line under the writing, such as the name of a section ("Nord") or a task ("Evakuierung"). */
|
|
92
|
+
subtitle?: string
|
|
93
|
+
/** Writing in the lower right corner inside the form (field B), such as an origin ("DLRG", "AW"). */
|
|
94
|
+
fieldB?: string
|
|
95
|
+
/** Writing in the free fields X of 6.1, in the upper right and lower left corners, such as "TP" or "K". */
|
|
96
|
+
fieldX?: {upperRight?: string, lowerLeft?: string}
|
|
97
|
+
/** The administrative level of 5.7, from 1 (municipality) to 6 (European Union), as stars above the form. */
|
|
98
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6
|
|
99
|
+
/** A strength of 5.3 below the form, such as "1/1/6/40/48"; the last number, the total, is underlined. */
|
|
100
|
+
strength?: string
|
|
101
|
+
/** A time of 5.6 to the left of the form, such as "040835jun23". */
|
|
102
|
+
time?: string
|
|
103
|
+
/** An identification of 6.2 to the right of the form, such as "2-1-3". */
|
|
104
|
+
identification?: string
|
|
105
|
+
/** A presumption (5.8.1.13, "?") or an acute situation (5.8.1.14, "!") written before the form. */
|
|
106
|
+
certainty?: 'presumed' | 'acute'
|
|
107
|
+
/** A figure of annex D.2 inside the form, such as the tray of a staging area. */
|
|
108
|
+
figure?: SignFigure
|
|
109
|
+
/** Draws the dashed line to the location of a command post (D.1.1) below the form. */
|
|
110
|
+
located?: boolean
|
|
89
111
|
/** Writing inside the form, such as a function or a vehicle name. */
|
|
90
112
|
text?: string
|
|
91
113
|
/** Shows the organisation's short name, which chapter 2 asks for whenever colour is missing. */
|
|
@@ -104,10 +126,6 @@ export const ORGANISATION_COLOURS: Readonly<Record<SignOrganisation, Readonly<{f
|
|
|
104
126
|
civil: {fill: '#BEBEBE', text: '#000000', abbreviation: 'ZIV'},
|
|
105
127
|
}
|
|
106
128
|
|
|
107
|
-
const BLACK = '#000000'
|
|
108
|
-
const WHITE = '#FFFFFF'
|
|
109
|
-
const HAZARD_RED = '#FA321E'
|
|
110
|
-
const MEASURE_BLUE = '#3264FA'
|
|
111
129
|
const STROKE = 3
|
|
112
130
|
|
|
113
131
|
/** Where a form lies on the canvas and where its writing, bars and short name go. */
|
|
@@ -126,6 +144,12 @@ interface Layout {
|
|
|
126
144
|
logisticsBar: string
|
|
127
145
|
/** Where the short name sits; outside the form where the form has no room for it. */
|
|
128
146
|
short: {x: number, y: number, inside: boolean}
|
|
147
|
+
/** The font size of writing inside the form where the form is too small for the usual size. */
|
|
148
|
+
textSize?: number
|
|
149
|
+
/** A filled cap in place of the command bar, where the form has no room for a bar (the tip of a person). */
|
|
150
|
+
commandCap?: string
|
|
151
|
+
/** The room for abilities and figures where it is narrower than the bounds, as in a diamond. */
|
|
152
|
+
room?: {left: number, right: number, top: number, bottom: number}
|
|
129
153
|
}
|
|
130
154
|
|
|
131
155
|
/** A layout with straight bars inset from the bounds and the short name in the lower right corner. */
|
|
@@ -146,7 +170,7 @@ const SHORT_BESIDE = {x: 104, y: 42, inside: false}
|
|
|
146
170
|
const FORMS: Record<BasicForm, Layout> = {
|
|
147
171
|
'formation': layout('M10 16 H110 V68 H10 Z', 10, 110, 16, 68, 86, 42),
|
|
148
172
|
'person': layout('M60 16 L86 42 L60 68 L34 42 Z', 34, 86, 16, 68, 30, 42,
|
|
149
|
-
{
|
|
173
|
+
{commandCap: 'M60 16 L71 27 H49 Z', logisticsBar: 'M48 56 H72', short: SHORT_BESIDE, textSize: 13, room: {left: 46, right: 74, top: 26, bottom: 58}}),
|
|
150
174
|
'land-vehicle': layout('M10 16 Q60 24 110 16 V60 H10 Z', 10, 110, 16, 60, 86, 40, {commandBar: 'M15 23 Q60 31 105 23'}),
|
|
151
175
|
'aircraft': layout('M22 62 A38 38 0 0 1 98 62 Z', 22, 98, 24, 62, 56, 48,
|
|
152
176
|
{commandBar: 'M40 34 H80', short: {x: 84, y: 56, inside: true}}),
|
|
@@ -218,26 +242,13 @@ function sizeMark(size: SignSize, above: number): SvgElement[] {
|
|
|
218
242
|
}
|
|
219
243
|
}
|
|
220
244
|
|
|
221
|
-
const ABILITY_STROKE = 2.5
|
|
222
|
-
|
|
223
|
-
/** One part of an ability, drawn in its 100 × 60 box; `width` is the stroke width in that box. */
|
|
224
|
-
function abilityPart(part: AbilityPart, colour: string, width: number): SvgElement {
|
|
225
|
-
const stroke = {stroke: colour, 'stroke-width': round(width), 'stroke-linecap': 'round', 'stroke-linejoin': 'round'}
|
|
226
|
-
if ('text' in part) {
|
|
227
|
-
return {tag: 'text', attributes: {x: part.x, y: part.y, fill: colour, 'font-size': part.size, ...SIGN_FONT,
|
|
228
|
-
'text-anchor': 'middle', 'dominant-baseline': 'central'}, text: part.text}
|
|
229
|
-
}
|
|
230
|
-
const fill = part.filled ? colour : 'none'
|
|
231
|
-
if ('circle' in part) return element('circle', {cx: part.circle[0], cy: part.circle[1], r: part.circle[2], fill, ...stroke})
|
|
232
|
-
return element('path', {d: part.d, fill, ...stroke, ...(part.width ? {'stroke-width': round(part.width * width / ABILITY_STROKE)} : {})})
|
|
233
|
-
}
|
|
234
|
-
|
|
235
245
|
/** The room inside a form that abilities may take, clear of the designation and the command and logistics bars. */
|
|
236
246
|
function abilityRoom(spec: TacticalSignSpec, form: Layout): {left: number, top: number, width: number, height: number} {
|
|
237
247
|
const supplements = spec.supplements ?? []
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
248
|
+
const bounds = form.room ?? {left: form.left + 6, right: form.right - 6, top: form.top + 4, bottom: form.bottom - 4}
|
|
249
|
+
const top = (form.room ? bounds.top : bounds.top + (supplements.includes('command') ? 8 : 0)) + (spec.designation || spec.fieldX?.upperRight ? 10 : 0)
|
|
250
|
+
const bottom = supplements.includes('logistics') ? Math.min(bounds.bottom, form.bottom - 12) : bounds.bottom
|
|
251
|
+
return {left: bounds.left, top, width: bounds.right - bounds.left, height: bottom - top}
|
|
241
252
|
}
|
|
242
253
|
|
|
243
254
|
/**
|
|
@@ -254,10 +265,10 @@ function abilityMarks(spec: TacticalSignSpec, form: Layout, colour: string): Svg
|
|
|
254
265
|
if (only?.stretch) {
|
|
255
266
|
const sx = room.width / 100
|
|
256
267
|
const sy = room.height / 60
|
|
257
|
-
const lines = only.parts.filter(part => !('circle' in part)).map(part =>
|
|
268
|
+
const lines = only.parts.filter(part => !('circle' in part)).map(part => boxPart(part, colour, BOX_STROKE / Math.min(sx, sy)))
|
|
258
269
|
const dots = only.parts.flatMap(part => 'circle' in part
|
|
259
270
|
? [element('circle', {cx: round(room.left + part.circle[0] * sx), cy: round(room.top + part.circle[1] * sy),
|
|
260
|
-
r: round(part.circle[2] * Math.min(sx, sy)), fill: part.filled ? colour : 'none', stroke: colour, 'stroke-width':
|
|
271
|
+
r: round(part.circle[2] * Math.min(sx, sy)), fill: part.filled ? colour : 'none', stroke: colour, 'stroke-width': BOX_STROKE})]
|
|
261
272
|
: [])
|
|
262
273
|
return [group(lines, {transform: `translate(${round(room.left)} ${round(room.top)}) scale(${round(sx)} ${round(sy)})`}), ...dots]
|
|
263
274
|
}
|
|
@@ -266,15 +277,11 @@ function abilityMarks(spec: TacticalSignSpec, form: Layout, colour: string): Svg
|
|
|
266
277
|
const scale = Math.min(room.width / 100, slot / 60)
|
|
267
278
|
const x = room.left + (room.width - 100 * scale) / 2
|
|
268
279
|
const y = room.top + slot * (names.length - 1 - index) + (slot - 60 * scale) / 2
|
|
269
|
-
const parts = ABILITIES[name].parts.map(part =>
|
|
280
|
+
const parts = ABILITIES[name].parts.map(part => boxPart(part, colour, BOX_STROKE / scale))
|
|
270
281
|
return group(parts, {transform: `translate(${round(x)} ${round(y)}) scale(${round(scale)})`})
|
|
271
282
|
})
|
|
272
283
|
}
|
|
273
284
|
|
|
274
|
-
function round(value: number): number {
|
|
275
|
-
return Math.round(value * 1000) / 1000
|
|
276
|
-
}
|
|
277
|
-
|
|
278
285
|
/** The designation in the upper left corner of a form (field A), below a command bar if there is one. */
|
|
279
286
|
function designation(spec: TacticalSignSpec, text: string, form: Layout, colour: string): SvgElement {
|
|
280
287
|
const below = (spec.supplements ?? []).includes('command') ? 12 : 0
|
|
@@ -296,7 +303,9 @@ const ROOF_HEIGHT = 11
|
|
|
296
303
|
function supplement(kind: Supplement, form: Layout, colour: string): SvgElement[] {
|
|
297
304
|
const y = form.textY
|
|
298
305
|
switch (kind) {
|
|
299
|
-
case 'command': return
|
|
306
|
+
case 'command': return form.commandCap
|
|
307
|
+
? [element('path', {d: form.commandCap, fill: BLACK, stroke: BLACK, 'stroke-width': 2, 'stroke-linejoin': 'round'})]
|
|
308
|
+
: [line(form.commandBar, BLACK, 5)]
|
|
300
309
|
case 'logistics': return [line(form.logisticsBar, BLACK, 5)]
|
|
301
310
|
case 'special-function': return [line(`M52 ${form.top + 8} H68`, colour)]
|
|
302
311
|
case 'uncrewed': return [line(`M50 ${y - 14} L60 ${y - 6} L70 ${y - 14}`, colour, 4)]
|
|
@@ -410,11 +419,144 @@ export function tacticalSignTree(spec: TacticalSignSpec): SvgElement {
|
|
|
410
419
|
for (const kind of supplements) parts.push(...supplement(kind, form, colours.line))
|
|
411
420
|
if (spec.size) parts.push(...sizeMark(spec.size, form.top))
|
|
412
421
|
if (spec.abilities?.length) parts.push(...abilityMarks(spec, form, colours.text))
|
|
422
|
+
if (spec.figure) parts.push(figureMark(spec, spec.figure, form, colours.text))
|
|
413
423
|
if (spec.designation) parts.push(designation(spec, spec.designation, form, colours.text))
|
|
414
|
-
|
|
424
|
+
const underBar = spec.form === 'place' && (spec.supplements ?? []).includes('command') ? 4 : 0
|
|
425
|
+
const textY = (spec.subtitle ? form.textY - 5 : form.textY) + underBar
|
|
426
|
+
if (spec.text) parts.push(label(spec.text, 60, textY, colours.text, form.textWidth, form.textSize))
|
|
427
|
+
if (spec.subtitle) parts.push(label(spec.subtitle, 60, textY + 13, colours.text, form.textWidth, 9))
|
|
428
|
+
parts.push(...cornerFields(spec, form, colours.text))
|
|
415
429
|
const short = spec.abbreviation && spec.organisation ? ORGANISATION_COLOURS[spec.organisation].abbreviation : ''
|
|
416
430
|
if (short) parts.push(label(short, form.short.x, form.short.y, form.short.inside ? colours.text : BLACK, 24, 10))
|
|
417
|
-
|
|
431
|
+
const margins = {left: 0, right: 0, top: 0, bottom: 0}
|
|
432
|
+
if (spec.level) {
|
|
433
|
+
const raised = spec.size !== undefined || (spec.supplements ?? []).includes('roof')
|
|
434
|
+
const y = raised ? form.top - (spec.level === 6 ? 26 : 20) : form.top - (spec.level === 6 ? 9 : 7)
|
|
435
|
+
parts.push(stars(spec.level, y))
|
|
436
|
+
const highest = y + Math.min(...starOffsets(spec.level).map(([, dy]) => dy)) - STAR_RADIUS(spec.level) - 1
|
|
437
|
+
margins.top = Math.max(0, Math.ceil(-highest))
|
|
438
|
+
}
|
|
439
|
+
const below = form.bottom + (spec.drive || spec.body ? 14 : 2)
|
|
440
|
+
if (spec.located) {
|
|
441
|
+
parts.push(...locationLine(form))
|
|
442
|
+
margins.bottom = form.bottom + 36 - SYMBOL_HEIGHT
|
|
443
|
+
}
|
|
444
|
+
if (spec.strength) {
|
|
445
|
+
const y = spec.located ? form.bottom + 44 : below + 8
|
|
446
|
+
parts.push(...strengthMark(spec.strength, y))
|
|
447
|
+
margins.bottom = Math.max(margins.bottom, y + 6 - SYMBOL_HEIGHT)
|
|
448
|
+
}
|
|
449
|
+
const ink = spec.style === 'mono' ? BLACK : HAZARD_RED
|
|
450
|
+
let left = form.left - 6
|
|
451
|
+
if (spec.certainty) {
|
|
452
|
+
parts.push(corner(spec.certainty === 'presumed' ? '?' : '!', left, form.textY, ink, 'end', 28))
|
|
453
|
+
left -= writingWidth('?', 28) + 4
|
|
454
|
+
}
|
|
455
|
+
if (spec.time) {
|
|
456
|
+
parts.push(beside(spec.time, left, form.textY, 'end'))
|
|
457
|
+
left -= writingWidth(spec.time, BESIDE_SIZE)
|
|
458
|
+
}
|
|
459
|
+
margins.left = Math.max(0, Math.ceil(2 - left))
|
|
460
|
+
if (spec.identification) {
|
|
461
|
+
const start = short && !form.short.inside ? form.short.x + writingWidth(short, 10) / 2 + 4 : form.right + 6
|
|
462
|
+
parts.push(beside(spec.identification, start, form.textY, 'start'))
|
|
463
|
+
margins.right = Math.max(0, Math.ceil(start + writingWidth(spec.identification, BESIDE_SIZE) + 2 - SYMBOL_WIDTH))
|
|
464
|
+
}
|
|
465
|
+
return canvas([group(parts)], margins)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Field B in the lower right and the fields X of 6.1 in the upper right and lower left corners:
|
|
470
|
+
* inside the form where it has room, otherwise just outside, beside its edges.
|
|
471
|
+
*/
|
|
472
|
+
function cornerFields(spec: TacticalSignSpec, form: Layout, colour: string): SvgElement[] {
|
|
473
|
+
const below = (spec.supplements ?? []).includes('command') && !form.commandCap ? 12 : 0
|
|
474
|
+
const inside = form.short.inside
|
|
475
|
+
const low = form.bottom - 6 - ((spec.supplements ?? []).includes('logistics') ? 8 : 0)
|
|
476
|
+
const fields: SvgElement[] = []
|
|
477
|
+
if (spec.fieldB) {
|
|
478
|
+
fields.push(inside ? corner(spec.fieldB, form.right - 4, low, colour, 'end') : corner(spec.fieldB, 66, form.bottom - 2, BLACK, 'start', 8))
|
|
479
|
+
}
|
|
480
|
+
if (spec.fieldX?.upperRight) {
|
|
481
|
+
fields.push(inside
|
|
482
|
+
? corner(spec.fieldX.upperRight, form.right - 4, form.top + 8 + below, colour, 'end')
|
|
483
|
+
: corner(spec.fieldX.upperRight, 66, form.top + 2, BLACK, 'start', 8))
|
|
484
|
+
}
|
|
485
|
+
if (spec.fieldX?.lowerLeft) {
|
|
486
|
+
fields.push(inside
|
|
487
|
+
? corner(spec.fieldX.lowerLeft, form.left + 5, low, colour, 'start')
|
|
488
|
+
: corner(spec.fieldX.lowerLeft, 54, form.bottom - 2, BLACK, 'end', 8))
|
|
489
|
+
}
|
|
490
|
+
return fields
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const BESIDE_SIZE = 12
|
|
494
|
+
|
|
495
|
+
/** Writing beside a sign, squeezed to its estimated width so the canvas margin always holds it, whatever font a map falls back to. */
|
|
496
|
+
function beside(text: string, x: number, y: number, anchor: 'start' | 'end'): SvgElement {
|
|
497
|
+
const writing = corner(text, x, y, BLACK, anchor, BESIDE_SIZE)
|
|
498
|
+
return {...writing, attributes: {...writing.attributes, textLength: writingWidth(text, BESIDE_SIZE), lengthAdjust: 'spacingAndGlyphs'}}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/** Roughly how wide a line of writing is in the sign font, to make room for it beside the sign. */
|
|
502
|
+
function writingWidth(text: string, size: number): number {
|
|
503
|
+
return Math.ceil(text.length * size * 0.55)
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Writing anchored at its start or end, for corners and the writing beside a sign. */
|
|
507
|
+
function corner(text: string, x: number, y: number, colour: string, anchor: 'start' | 'end', size = 9): SvgElement {
|
|
508
|
+
return {tag: 'text', attributes: {x, y, fill: colour, 'font-size': size, ...SIGN_FONT, 'text-anchor': anchor, 'dominant-baseline': 'central'}, text}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** The size of the stars above a form; the ring of the European Union has smaller ones. */
|
|
512
|
+
const STAR_RADIUS = (level: number) => level === 6 ? 3 : 4
|
|
513
|
+
|
|
514
|
+
/** The stars of an administrative level (5.7) above a form; the European Union gets its ring of stars. */
|
|
515
|
+
function stars(level: number, y: number): SvgElement {
|
|
516
|
+
return element('path', {d: starOffsets(level).map(([dx, dy]) => asterisk(60 + dx, y + dy, STAR_RADIUS(level))).join(' '), fill: 'none', stroke: BLACK,
|
|
517
|
+
'stroke-width': 1.5, 'stroke-linecap': 'round'})
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/** The figures of annex D.2 drawn inside a place, on the 100 × 60 box of the abilities. */
|
|
521
|
+
export const SIGN_FIGURES = {
|
|
522
|
+
'staging-area': [{d: 'M18 18 Q50 30 82 18 V50 H18 Z'}],
|
|
523
|
+
'staging-area-with-report': [{d: 'M22 30 Q50 40 78 30 V58 H22 Z'}, {text: 'M', x: 50, y: 12, size: 24}],
|
|
524
|
+
'landing-zone': [{d: 'M24 18 L50 30 L24 42 Z M76 18 L50 30 L76 42 Z', filled: true}, {d: 'M14 30 H86'}],
|
|
525
|
+
} as const satisfies Record<string, readonly BoxPart[]>
|
|
526
|
+
|
|
527
|
+
/** A figure of annex D.2. */
|
|
528
|
+
export type SignFigure = keyof typeof SIGN_FIGURES
|
|
529
|
+
|
|
530
|
+
/** A figure inside a form, scaled evenly into the room the abilities would take. */
|
|
531
|
+
function figureMark(spec: TacticalSignSpec, figure: SignFigure, form: Layout, colour: string): SvgElement {
|
|
532
|
+
const room = abilityRoom(spec, form)
|
|
533
|
+
const scale = Math.min(room.width / 100, room.height / 60)
|
|
534
|
+
const x = room.left + (room.width - 100 * scale) / 2
|
|
535
|
+
const y = room.top + (room.height - 60 * scale) / 2
|
|
536
|
+
return group(SIGN_FIGURES[figure].map(part => boxPart(part, colour, BOX_STROKE / scale)),
|
|
537
|
+
{transform: `translate(${round(x)} ${round(y)}) scale(${round(scale)})`})
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** The dashed line from a command post to its location on the map, ending in a cross (D.1.1). */
|
|
541
|
+
function locationLine(form: Layout): SvgElement[] {
|
|
542
|
+
const end = {x: form.left + 76, y: form.bottom + 30}
|
|
543
|
+
return [
|
|
544
|
+
element('path', {d: `M${form.left} ${form.bottom} L${end.x} ${end.y}`, stroke: BLACK, 'stroke-width': 1.5, 'stroke-dasharray': '4 3', fill: 'none'}),
|
|
545
|
+
element('path', {d: `M${end.x - 4} ${end.y - 4} L${end.x + 4} ${end.y + 4} M${end.x + 4} ${end.y - 4} L${end.x - 4} ${end.y + 4}`,
|
|
546
|
+
stroke: BLACK, 'stroke-width': 1.5}),
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** A strength of 5.3 below the form, its last number, the total, underlined. */
|
|
551
|
+
function strengthMark(strength: string, y: number): SvgElement[] {
|
|
552
|
+
const parts = strength.split('/')
|
|
553
|
+
const total = parts.pop() ?? ''
|
|
554
|
+
const head = parts.length ? `${parts.join('/')}/` : ''
|
|
555
|
+
return [{tag: 'text', attributes: {x: 60, y, fill: BLACK, 'font-size': 11, ...SIGN_FONT, 'text-anchor': 'middle', 'dominant-baseline': 'central'},
|
|
556
|
+
children: [
|
|
557
|
+
{tag: 'tspan', attributes: {}, text: head},
|
|
558
|
+
{tag: 'tspan', attributes: {'text-decoration': 'underline'}, text: total},
|
|
559
|
+
]}]
|
|
418
560
|
}
|
|
419
561
|
|
|
420
562
|
/** The sign as SVG markup, for map icons. */
|
package/src/symbols/svg.ts
CHANGED
|
@@ -70,14 +70,84 @@ export function label(text: string, x: number, y: number, colour: string, maxWid
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
export
|
|
73
|
+
/** How far a canvas reaches beyond the common 120 × 80 area on each side, for writing around a sign. */
|
|
74
|
+
export interface Margins {
|
|
75
|
+
left: number
|
|
76
|
+
right: number
|
|
77
|
+
top: number
|
|
78
|
+
bottom: number
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The SVG element of the common 120 × 80 canvas around a symbol's content, widened by `margins`
|
|
83
|
+
* where writing sits beside or below the sign; the sign itself keeps its place and size.
|
|
84
|
+
*/
|
|
85
|
+
export function canvas(children: SvgElement[], margins: Margins = {left: 0, right: 0, top: 0, bottom: 0}): SvgElement {
|
|
86
|
+
const width = SYMBOL_WIDTH + margins.left + margins.right
|
|
87
|
+
const height = SYMBOL_HEIGHT + margins.top + margins.bottom
|
|
75
88
|
return {
|
|
76
89
|
tag: 'svg',
|
|
77
90
|
attributes: {
|
|
78
|
-
xmlns: 'http://www.w3.org/2000/svg', viewBox:
|
|
79
|
-
width
|
|
91
|
+
xmlns: 'http://www.w3.org/2000/svg', viewBox: `${-margins.left} ${-margins.top} ${width} ${height}`,
|
|
92
|
+
width, height,
|
|
80
93
|
},
|
|
81
94
|
children,
|
|
82
95
|
}
|
|
83
96
|
}
|
|
97
|
+
|
|
98
|
+
/** Rounds a coordinate or factor to three decimals, to keep the markup short. */
|
|
99
|
+
export function round(value: number): number {
|
|
100
|
+
return Math.round(value * 1000) / 1000
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* One stroke, filled shape or piece of writing of a drawing on its own 100 × 60 box, as the
|
|
105
|
+
* abilities of chapter 4 and the additional signs of chapter 5 are drawn; `colour` overrides the
|
|
106
|
+
* drawing's colour for this part.
|
|
107
|
+
*/
|
|
108
|
+
export type BoxPart = (
|
|
109
|
+
| {d: string, filled?: boolean, width?: number}
|
|
110
|
+
| {circle: [number, number, number], filled?: boolean}
|
|
111
|
+
| {text: string, x: number, y: number, size: number}
|
|
112
|
+
) & {colour?: string}
|
|
113
|
+
|
|
114
|
+
/** The stroke width of a drawing on its 100 × 60 box at its own size. */
|
|
115
|
+
export const BOX_STROKE = 2.5
|
|
116
|
+
|
|
117
|
+
/** One part of a box drawing; `width` is the stroke width in the box, so lines keep their weight however the box is scaled. */
|
|
118
|
+
export function boxPart(part: BoxPart, colour: string, width = BOX_STROKE): SvgElement {
|
|
119
|
+
const ink = part.colour ?? colour
|
|
120
|
+
const stroke = {stroke: ink, 'stroke-width': round(width), 'stroke-linecap': 'round', 'stroke-linejoin': 'round'}
|
|
121
|
+
if ('text' in part) {
|
|
122
|
+
return {tag: 'text', attributes: {x: part.x, y: part.y, fill: ink, 'font-size': part.size, ...SIGN_FONT,
|
|
123
|
+
'text-anchor': 'middle', 'dominant-baseline': 'central'}, text: part.text}
|
|
124
|
+
}
|
|
125
|
+
const fill = part.filled ? ink : 'none'
|
|
126
|
+
if ('circle' in part) return element('circle', {cx: part.circle[0], cy: part.circle[1], r: part.circle[2], fill, ...stroke})
|
|
127
|
+
return element('path', {d: part.d, fill, ...stroke, ...(part.width ? {'stroke-width': round(part.width * width / BOX_STROKE)} : {})})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The ink every sign is drawn in. */
|
|
131
|
+
export const BLACK = '#000000'
|
|
132
|
+
/** The white of filled forms and backdrops. */
|
|
133
|
+
export const WHITE = '#FFFFFF'
|
|
134
|
+
/** The red of hazards and damage (annex O, also the fire service colour). */
|
|
135
|
+
export const HAZARD_RED = '#FA321E'
|
|
136
|
+
/** The blue of measures and water (annex O). */
|
|
137
|
+
export const MEASURE_BLUE = '#3264FA'
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Where the stars of an administrative level (5.7) sit around their centre, 10 apart in a row; the
|
|
141
|
+
* European Union (level 6) has six in a ring: one left, two above, two below, one right.
|
|
142
|
+
*/
|
|
143
|
+
export function starOffsets(level: number): [number, number][] {
|
|
144
|
+
if (level === 6) return [[-14, 0], [-5, -5], [5, -5], [-5, 5], [5, 5], [14, 0]]
|
|
145
|
+
return Array.from({length: level}, (_, index) => [(index - (level - 1) / 2) * 10, 0])
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The path of a six-armed asterisk, the star of the administrative levels of 5.7. */
|
|
149
|
+
export function asterisk(x: number, y: number, r: number): string {
|
|
150
|
+
const dx = round(r * 0.866)
|
|
151
|
+
const dy = round(r / 2)
|
|
152
|
+
return `M${x} ${y - r} V${y + r} M${round(x - dx)} ${round(y - dy)} L${round(x + dx)} ${round(y + dy)} M${round(x + dx)} ${round(y - dy)} L${round(x - dx)} ${round(y + dy)}`
|
|
153
|
+
}
|