@oicl/openbridge-webcomponents 0.0.15-dev-20240916185711 → 0.0.15-dev-20240923190011
Sign up to get free protection for your applications and to get access to all the features.
- package/.storybook/main.ts +8 -0
- package/.storybook/preview.ts +2 -0
- package/__snapshots__/building-blocks-watch--advice.png +0 -0
- package/__snapshots__/building-blocks-watch-flat--primary.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster--in-command.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster-labeled--large.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster-labeled--medium.png +0 -0
- package/__snapshots__/navigation-instruments-azimuth-thruster-labeled--no-command.png +0 -0
- package/__snapshots__/navigation-instruments-compass--primary.png +0 -0
- package/__snapshots__/navigation-instruments-compass-flat--primary.png +0 -0
- package/__snapshots__/navigation-instruments-compass-flat--with-fov-indicator.png +0 -0
- package/custom-elements.json +968 -7
- package/dist/navigation-instruments/compass/arrow.d.ts +7 -0
- package/dist/navigation-instruments/compass/arrow.d.ts.map +1 -0
- package/dist/navigation-instruments/compass/arrow.js +59 -0
- package/dist/navigation-instruments/compass/arrow.js.map +1 -0
- package/dist/navigation-instruments/compass/compass.d.ts +23 -0
- package/dist/navigation-instruments/compass/compass.d.ts.map +1 -0
- package/dist/navigation-instruments/compass/compass.js +139 -0
- package/dist/navigation-instruments/compass/compass.js.map +1 -0
- package/dist/navigation-instruments/compass/radial-tickmark.d.ts +4 -0
- package/dist/navigation-instruments/compass/radial-tickmark.d.ts.map +1 -0
- package/dist/navigation-instruments/compass/radial-tickmark.js +69 -0
- package/dist/navigation-instruments/compass/radial-tickmark.js.map +1 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.css.js +29 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.css.js.map +1 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.d.ts +45 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.d.ts.map +1 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.js +223 -0
- package/dist/navigation-instruments/compass-flat/compass-flat.js.map +1 -0
- package/dist/navigation-instruments/thruster/advice.d.ts.map +1 -1
- package/dist/navigation-instruments/thruster/advice.js +9 -5
- package/dist/navigation-instruments/thruster/advice.js.map +1 -1
- package/dist/navigation-instruments/watch/advice.js +1 -1
- package/dist/navigation-instruments/watch/advice.js.map +1 -1
- package/dist/navigation-instruments/watch/label.d.ts +3 -0
- package/dist/navigation-instruments/watch/label.d.ts.map +1 -0
- package/dist/navigation-instruments/watch/label.js +68 -0
- package/dist/navigation-instruments/watch/label.js.map +1 -0
- package/dist/navigation-instruments/watch/watch.css.js +15 -14
- package/dist/navigation-instruments/watch/watch.css.js.map +1 -1
- package/dist/navigation-instruments/watch/watch.d.ts +3 -0
- package/dist/navigation-instruments/watch/watch.d.ts.map +1 -1
- package/dist/navigation-instruments/watch/watch.js +34 -1
- package/dist/navigation-instruments/watch/watch.js.map +1 -1
- package/dist/navigation-instruments/watch-flat/tickmark-flat.d.ts +20 -0
- package/dist/navigation-instruments/watch-flat/tickmark-flat.d.ts.map +1 -0
- package/dist/navigation-instruments/watch-flat/tickmark-flat.js +53 -0
- package/dist/navigation-instruments/watch-flat/tickmark-flat.js.map +1 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.css.js +32 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.css.js.map +1 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.d.ts +29 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.d.ts.map +1 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.js +184 -0
- package/dist/navigation-instruments/watch-flat/watch-flat.js.map +1 -0
- package/dist/svghelpers/rectangular.d.ts +1 -0
- package/dist/svghelpers/rectangular.d.ts.map +1 -1
- package/dist/svghelpers/rectangular.js +3 -2
- package/dist/svghelpers/rectangular.js.map +1 -1
- package/package.json +16 -11
- package/src/navigation-instruments/compass/arrow.ts +61 -0
- package/src/navigation-instruments/compass/compass.stories.ts +37 -0
- package/src/navigation-instruments/compass/compass.ts +132 -0
- package/src/navigation-instruments/compass/radial-tickmark.ts +77 -0
- package/src/navigation-instruments/compass-flat/compass-flat.css +23 -0
- package/src/navigation-instruments/compass-flat/compass-flat.stories.ts +35 -0
- package/src/navigation-instruments/compass-flat/compass-flat.ts +221 -0
- package/src/navigation-instruments/thruster/advice.ts +9 -5
- package/src/navigation-instruments/watch/advice.ts +1 -1
- package/src/navigation-instruments/watch/label.ts +69 -0
- package/src/navigation-instruments/watch/watch.css +7 -7
- package/src/navigation-instruments/watch/watch.ts +30 -1
- package/src/navigation-instruments/watch-flat/tickmark-flat.ts +62 -0
- package/src/navigation-instruments/watch-flat/watch-flat.css +19 -0
- package/src/navigation-instruments/watch-flat/watch-flat.stories.ts +17 -0
- package/src/navigation-instruments/watch-flat/watch-flat.ts +148 -0
- package/src/svghelpers/rectangular.ts +6 -3
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"arrow.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/compass/arrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAM,MAAM,KAAK,CAAC;AAE3C,oBAAY,UAAU;IACpB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,wBAAgB,KAAK,CACnB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,GACZ,iBAAiB,GAAG,iBAAiB,EAAE,CAkDzC"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { svg } from "lit";
|
2
|
+
var ArrowStyle = /* @__PURE__ */ ((ArrowStyle2) => {
|
3
|
+
ArrowStyle2["HDG"] = "HDG";
|
4
|
+
ArrowStyle2["COG"] = "COG";
|
5
|
+
return ArrowStyle2;
|
6
|
+
})(ArrowStyle || {});
|
7
|
+
function arrow(style, angle) {
|
8
|
+
const colorName = "var(--instrument-enhanced-secondary-color)";
|
9
|
+
if (style === "HDG") {
|
10
|
+
return svg`
|
11
|
+
<g transform="translate(-32, -${256}) rotate(${angle}, 32, 256)">
|
12
|
+
<rect x="28" y="118" width="8" height="139" rx="4" fill="${colorName}" />
|
13
|
+
<rect x="30.0039" y="256" width="4" height="156" rx="2" fill="${colorName}" />
|
14
|
+
<circle cx="32" cy="256" r="8" fill="${colorName}" />
|
15
|
+
<mask
|
16
|
+
id="mask0_262_65165"
|
17
|
+
style="mask-type:luminance"
|
18
|
+
maskUnits="userSpaceOnUse"
|
19
|
+
x="8"
|
20
|
+
y="94"
|
21
|
+
width="48"
|
22
|
+
height="50"
|
23
|
+
>
|
24
|
+
<path
|
25
|
+
d="M13.2833 140.564L32 96L50.7167 140.564C51.4569 142.326 49.54 144.023 47.8805 143.075L32 136L16.1195 143.075C14.46 144.023 12.5432 142.326 13.2833 140.564Z"
|
26
|
+
fill="white"
|
27
|
+
stroke="black"
|
28
|
+
/>
|
29
|
+
</mask>
|
30
|
+
<g mask="url(#mask0_262_65165)">
|
31
|
+
<path
|
32
|
+
d="M13.2833 140.564L32 96L50.7167 140.564C51.4569 142.326 49.54 144.023 47.8805 143.075L32 136L16.1195 143.075C14.46 144.023 12.5432 142.326 13.2833 140.564Z"
|
33
|
+
fill="${colorName}"
|
34
|
+
/>
|
35
|
+
</g>
|
36
|
+
</g>
|
37
|
+
`;
|
38
|
+
} else if (style === "COG") {
|
39
|
+
return svg`
|
40
|
+
<g transform="translate(-32, -${256}) rotate(${angle}, 32, 256)">
|
41
|
+
<path
|
42
|
+
fill-rule="evenodd"
|
43
|
+
clip-rule="evenodd"
|
44
|
+
d="M13.2833 140.564C12.5431 142.326 14.46 144.023 16.1195 143.075L32 136L47.8805 143.075C49.54 144.023 51.4568 142.326 50.7167 140.564L32 96L13.2833 140.564ZM32 106.33L19.2545 136.676L32 131.393L44.7455 136.676L32 106.33ZM49.865 139.602L49.8625 139.6L49.865 139.602Z"
|
45
|
+
fill="${colorName}"
|
46
|
+
/>
|
47
|
+
<rect x="30" y="133" width="4" height="124" rx="2" fill="${colorName}" />
|
48
|
+
<circle cx="32" cy="256" r="4" fill="${colorName}" />
|
49
|
+
</g>
|
50
|
+
`;
|
51
|
+
} else {
|
52
|
+
return [];
|
53
|
+
}
|
54
|
+
}
|
55
|
+
export {
|
56
|
+
ArrowStyle,
|
57
|
+
arrow
|
58
|
+
};
|
59
|
+
//# sourceMappingURL=arrow.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"arrow.js","sources":["../../../src/navigation-instruments/compass/arrow.ts"],"sourcesContent":["import {SVGTemplateResult, svg} from 'lit';\n\nexport enum ArrowStyle {\n HDG = 'HDG',\n COG = 'COG',\n}\n\nexport function arrow(\n style: ArrowStyle,\n angle: number\n): SVGTemplateResult | SVGTemplateResult[] {\n const colorName = 'var(--instrument-enhanced-secondary-color)';\n\n if (style === ArrowStyle.HDG) {\n return svg`\n <g transform=\"translate(-32, -${256}) rotate(${angle}, 32, 256)\">\n <rect x=\"28\" y=\"118\" width=\"8\" height=\"139\" rx=\"4\" fill=\"${colorName}\" />\n <rect x=\"30.0039\" y=\"256\" width=\"4\" height=\"156\" rx=\"2\" fill=\"${colorName}\" />\n <circle cx=\"32\" cy=\"256\" r=\"8\" fill=\"${colorName}\" />\n <mask\n id=\"mask0_262_65165\"\n style=\"mask-type:luminance\"\n maskUnits=\"userSpaceOnUse\"\n x=\"8\"\n y=\"94\"\n width=\"48\"\n height=\"50\"\n >\n <path\n d=\"M13.2833 140.564L32 96L50.7167 140.564C51.4569 142.326 49.54 144.023 47.8805 143.075L32 136L16.1195 143.075C14.46 144.023 12.5432 142.326 13.2833 140.564Z\"\n fill=\"white\"\n stroke=\"black\"\n />\n </mask>\n <g mask=\"url(#mask0_262_65165)\">\n <path\n d=\"M13.2833 140.564L32 96L50.7167 140.564C51.4569 142.326 49.54 144.023 47.8805 143.075L32 136L16.1195 143.075C14.46 144.023 12.5432 142.326 13.2833 140.564Z\"\n fill=\"${colorName}\"\n />\n </g>\n </g>\n `;\n } else if (style === ArrowStyle.COG) {\n return svg`\n <g transform=\"translate(-32, -${256}) rotate(${angle}, 32, 256)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M13.2833 140.564C12.5431 142.326 14.46 144.023 16.1195 143.075L32 136L47.8805 143.075C49.54 144.023 51.4568 142.326 50.7167 140.564L32 96L13.2833 140.564ZM32 106.33L19.2545 136.676L32 131.393L44.7455 136.676L32 106.33ZM49.865 139.602L49.8625 139.6L49.865 139.602Z\"\n fill=\"${colorName}\"\n />\n <rect x=\"30\" y=\"133\" width=\"4\" height=\"124\" rx=\"2\" fill=\"${colorName}\" />\n <circle cx=\"32\" cy=\"256\" r=\"4\" fill=\"${colorName}\" />\n </g>\n `;\n } else {\n return [];\n }\n\n // return [...shaft, circle, arrowTip];\n}\n"],"names":["ArrowStyle"],"mappings":";AAEY,IAAA,+BAAAA,gBAAL;AACLA,cAAA,KAAM,IAAA;AACNA,cAAA,KAAM,IAAA;AAFIA,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AAKI,SAAA,MACd,OACA,OACyC;AACzC,QAAM,YAAY;AAElB,MAAI,UAAU,OAAgB;AACrB,WAAA;AAAA,sCAC2B,GAAG,YAAY,KAAK;AAAA,mEACS,SAAS;AAAA,wEACJ,SAAS;AAAA,+CAClC,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAmBpC,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA,WAKhB,UAAU,OAAgB;AAC5B,WAAA;AAAA,sCAC2B,GAAG,YAAY,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA,kBAKxC,SAAS;AAAA;AAAA,mEAEwC,SAAS;AAAA,+CAC7B,SAAS;AAAA;AAAA;AAAA,EAAA,OAG/C;AACL,WAAO;EACT;AAGF;"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import '../watch/watch';
|
3
|
+
import { AngleAdvice } from '../watch/advice';
|
4
|
+
export declare class ObcCompass extends LitElement {
|
5
|
+
heading: number;
|
6
|
+
courseOverGround: number;
|
7
|
+
padding: number;
|
8
|
+
headingAdvices: AngleAdvice[];
|
9
|
+
containerWidth: number;
|
10
|
+
private resizeObserver;
|
11
|
+
connectedCallback(): void;
|
12
|
+
disconnectedCallback(): void;
|
13
|
+
private adjustPadding;
|
14
|
+
private get angleAdviceRaw();
|
15
|
+
render(): import("lit-html").TemplateResult<1>;
|
16
|
+
static styles: import("lit").CSSResult;
|
17
|
+
}
|
18
|
+
declare global {
|
19
|
+
interface HTMLElementTagNameMap {
|
20
|
+
'obc-compass': ObcCompass;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
//# sourceMappingURL=compass.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"compass.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/compass/compass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAY,MAAM,KAAK,CAAC;AAE1C,OAAO,gBAAgB,CAAC;AAGxB,OAAO,EAGL,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AAGzB,qBACa,UAAW,SAAQ,UAAU;IACd,OAAO,SAAK;IACZ,gBAAgB,SAAK;IACrB,OAAO,SAAM;IACI,cAAc,EAAE,WAAW,EAAE,CAAM;IACpD,cAAc,SAAK;IAE7C,OAAO,CAAC,cAAc,CAKnB;IAEM,iBAAiB;IAKjB,oBAAoB;IAK7B,OAAO,CAAC,aAAa;IAarB,OAAO,KAAK,cAAc,GAUzB;IAEQ,MAAM;IAqCf,OAAgB,MAAM,0BAwBpB;CACH;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
@@ -0,0 +1,139 @@
|
|
1
|
+
import { css, LitElement, html } from "lit";
|
2
|
+
import { property, customElement } from "lit/decorators.js";
|
3
|
+
import "../watch/watch.js";
|
4
|
+
import { TickmarkType } from "../watch/tickmark.js";
|
5
|
+
import { arrow, ArrowStyle } from "./arrow.js";
|
6
|
+
import { AdviceState, AdviceType } from "../watch/advice.js";
|
7
|
+
import { radialTickmarks } from "./radial-tickmark.js";
|
8
|
+
var __defProp = Object.defineProperty;
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
11
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
13
|
+
if (decorator = decorators[i])
|
14
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
15
|
+
if (kind && result)
|
16
|
+
__defProp(target, key, result);
|
17
|
+
return result;
|
18
|
+
};
|
19
|
+
let ObcCompass = class extends LitElement {
|
20
|
+
constructor() {
|
21
|
+
super(...arguments);
|
22
|
+
this.heading = 0;
|
23
|
+
this.courseOverGround = 0;
|
24
|
+
this.padding = 48;
|
25
|
+
this.headingAdvices = [];
|
26
|
+
this.containerWidth = 0;
|
27
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
28
|
+
for (const entry of entries) {
|
29
|
+
this.containerWidth = entry.contentRect.width;
|
30
|
+
this.adjustPadding();
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
connectedCallback() {
|
35
|
+
super.connectedCallback();
|
36
|
+
this.resizeObserver.observe(this);
|
37
|
+
}
|
38
|
+
disconnectedCallback() {
|
39
|
+
super.disconnectedCallback();
|
40
|
+
this.resizeObserver.unobserve(this);
|
41
|
+
}
|
42
|
+
adjustPadding() {
|
43
|
+
const deltaWidth = 512 - this.containerWidth;
|
44
|
+
const steps = deltaWidth / 128;
|
45
|
+
let deltaPadding = 0;
|
46
|
+
if (deltaWidth > 0) {
|
47
|
+
deltaPadding = steps * 48;
|
48
|
+
} else {
|
49
|
+
deltaPadding = steps * 6;
|
50
|
+
}
|
51
|
+
this.padding = 72 + deltaPadding;
|
52
|
+
}
|
53
|
+
get angleAdviceRaw() {
|
54
|
+
return this.headingAdvices.map(({ minAngle, maxAngle, hinted, type }) => {
|
55
|
+
const state = this.heading >= minAngle && this.heading <= maxAngle ? AdviceState.triggered : hinted ? AdviceState.hinted : AdviceState.regular;
|
56
|
+
return { minAngle, maxAngle, type, state };
|
57
|
+
});
|
58
|
+
}
|
59
|
+
render() {
|
60
|
+
const tickmarks = [
|
61
|
+
{ angle: 0, type: TickmarkType.main },
|
62
|
+
{ angle: 90, type: TickmarkType.main },
|
63
|
+
{ angle: 180, type: TickmarkType.main },
|
64
|
+
{ angle: 270, type: TickmarkType.main }
|
65
|
+
];
|
66
|
+
const rt = this.headingAdvices.map(
|
67
|
+
({ minAngle, maxAngle, type }) => radialTickmarks(
|
68
|
+
minAngle,
|
69
|
+
maxAngle,
|
70
|
+
type === AdviceType.caution ? TickmarkType.secondary : void 0
|
71
|
+
)
|
72
|
+
);
|
73
|
+
const width = (176 + this.padding) * 2;
|
74
|
+
const viewBox = `-${width / 2} -${width / 2} ${width} ${width}`;
|
75
|
+
return html`
|
76
|
+
<div class="container">
|
77
|
+
<obc-watch
|
78
|
+
.padding=${this.padding}
|
79
|
+
.advices=${this.angleAdviceRaw}
|
80
|
+
.tickmarks=${tickmarks}
|
81
|
+
.labelFrameEnabled=${true}
|
82
|
+
.crosshairEnabled=${true}
|
83
|
+
>
|
84
|
+
</obc-watch>
|
85
|
+
<svg viewBox="${viewBox}">
|
86
|
+
${rt} ${arrow(ArrowStyle.HDG, this.heading)}
|
87
|
+
${arrow(ArrowStyle.COG, this.courseOverGround)}
|
88
|
+
</svg>
|
89
|
+
</div>
|
90
|
+
`;
|
91
|
+
}
|
92
|
+
};
|
93
|
+
ObcCompass.styles = css`
|
94
|
+
* {
|
95
|
+
box-sizing: border-box;
|
96
|
+
}
|
97
|
+
|
98
|
+
.container {
|
99
|
+
position: relative;
|
100
|
+
width: 100%;
|
101
|
+
height: 100%;
|
102
|
+
}
|
103
|
+
|
104
|
+
.container > * {
|
105
|
+
position: absolute;
|
106
|
+
top: 0;
|
107
|
+
left: 0;
|
108
|
+
width: 100%;
|
109
|
+
height: 100%;
|
110
|
+
}
|
111
|
+
|
112
|
+
:host {
|
113
|
+
display: block;
|
114
|
+
width: 100%;
|
115
|
+
height: 100%;
|
116
|
+
}
|
117
|
+
`;
|
118
|
+
__decorateClass([
|
119
|
+
property({ type: Number })
|
120
|
+
], ObcCompass.prototype, "heading", 2);
|
121
|
+
__decorateClass([
|
122
|
+
property({ type: Number })
|
123
|
+
], ObcCompass.prototype, "courseOverGround", 2);
|
124
|
+
__decorateClass([
|
125
|
+
property({ type: Number })
|
126
|
+
], ObcCompass.prototype, "padding", 2);
|
127
|
+
__decorateClass([
|
128
|
+
property({ type: Array, attribute: false })
|
129
|
+
], ObcCompass.prototype, "headingAdvices", 2);
|
130
|
+
__decorateClass([
|
131
|
+
property({ type: Number })
|
132
|
+
], ObcCompass.prototype, "containerWidth", 2);
|
133
|
+
ObcCompass = __decorateClass([
|
134
|
+
customElement("obc-compass")
|
135
|
+
], ObcCompass);
|
136
|
+
export {
|
137
|
+
ObcCompass
|
138
|
+
};
|
139
|
+
//# sourceMappingURL=compass.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"compass.js","sources":["../../../src/navigation-instruments/compass/compass.ts"],"sourcesContent":["import {LitElement, css, html} from 'lit';\nimport {customElement, property} from 'lit/decorators.js';\nimport '../watch/watch';\nimport {Tickmark, TickmarkType} from '../watch/tickmark';\nimport {arrow, ArrowStyle} from './arrow';\nimport {\n AdviceState,\n AdviceType,\n AngleAdvice,\n AngleAdviceRaw,\n} from '../watch/advice';\nimport {radialTickmarks} from './radial-tickmark';\n\n@customElement('obc-compass')\nexport class ObcCompass extends LitElement {\n @property({type: Number}) heading = 0;\n @property({type: Number}) courseOverGround = 0;\n @property({type: Number}) padding = 48;\n @property({type: Array, attribute: false}) headingAdvices: AngleAdvice[] = [];\n @property({type: Number}) containerWidth = 0;\n\n private resizeObserver: ResizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n this.containerWidth = entry.contentRect.width;\n this.adjustPadding();\n }\n });\n\n override connectedCallback() {\n super.connectedCallback();\n this.resizeObserver.observe(this);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.resizeObserver.unobserve(this);\n }\n\n private adjustPadding() {\n const deltaWidth = 512 - this.containerWidth;\n const steps = deltaWidth / 128;\n let deltaPadding = 0;\n if (deltaWidth > 0) {\n deltaPadding = steps * 48;\n } else {\n deltaPadding = steps * 6;\n }\n\n this.padding = 72 + deltaPadding;\n }\n\n private get angleAdviceRaw(): AngleAdviceRaw[] {\n return this.headingAdvices.map(({minAngle, maxAngle, hinted, type}) => {\n const state =\n this.heading >= minAngle && this.heading <= maxAngle\n ? AdviceState.triggered\n : hinted\n ? AdviceState.hinted\n : AdviceState.regular;\n return {minAngle, maxAngle, type, state};\n });\n }\n\n override render() {\n const tickmarks: Tickmark[] = [\n {angle: 0, type: TickmarkType.main},\n {angle: 90, type: TickmarkType.main},\n {angle: 180, type: TickmarkType.main},\n {angle: 270, type: TickmarkType.main},\n ];\n\n const rt = this.headingAdvices.map(({minAngle, maxAngle, type}) =>\n radialTickmarks(\n minAngle,\n maxAngle,\n type === AdviceType.caution ? TickmarkType.secondary : undefined\n )\n );\n\n const width = (176 + this.padding) * 2;\n const viewBox = `-${width / 2} -${width / 2} ${width} ${width}`;\n\n return html`\n <div class=\"container\">\n <obc-watch\n .padding=${this.padding}\n .advices=${this.angleAdviceRaw}\n .tickmarks=${tickmarks}\n .labelFrameEnabled=${true}\n .crosshairEnabled=${true}\n >\n </obc-watch>\n <svg viewBox=\"${viewBox}\">\n ${rt} ${arrow(ArrowStyle.HDG, this.heading)}\n ${arrow(ArrowStyle.COG, this.courseOverGround)}\n </svg>\n </div>\n `;\n }\n\n static override styles = css`\n * {\n box-sizing: border-box;\n }\n\n .container {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .container > * {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n `;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'obc-compass': ObcCompass;\n }\n}\n"],"names":[],"mappings":"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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"radial-tickmark.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/compass/radial-tickmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAM,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAC,YAAY,EAA+B,MAAM,mBAAmB,CAAC;AAE7E,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,YAAY,GAAG,SAAS,GAC7B,iBAAiB,EAAE,CAqErB"}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { svg } from "lit";
|
2
|
+
import { TickmarkType, tickmarkColor, TickmarkStyle } from "../watch/tickmark.js";
|
3
|
+
function radialTickmarks(minAngle, maxAngle, type) {
|
4
|
+
if (type === TickmarkType.main || type === TickmarkType.tertiary) {
|
5
|
+
throw new Error(
|
6
|
+
"Only secondary tickmarks or undefined tickmarks (dots) are supported"
|
7
|
+
);
|
8
|
+
}
|
9
|
+
const origin = { x: 0, y: 0 };
|
10
|
+
const radius = 320 / 2;
|
11
|
+
const strokeWidth = "1.2";
|
12
|
+
const margin = 1.5;
|
13
|
+
const colorName = tickmarkColor(TickmarkStyle.hinted);
|
14
|
+
const tickWidth = type === TickmarkType.secondary ? 4 : 1;
|
15
|
+
const tickmarks = [];
|
16
|
+
const sinMin = Math.sin(minAngle * Math.PI / 180);
|
17
|
+
const cosMin = Math.cos(minAngle * Math.PI / 180);
|
18
|
+
const sinMax = Math.sin(maxAngle * Math.PI / 180);
|
19
|
+
const cosMax = Math.cos(maxAngle * Math.PI / 180);
|
20
|
+
const deltaIncrement = tickWidth * margin;
|
21
|
+
for (let deltaR = 0; deltaR <= radius; deltaR += deltaIncrement) {
|
22
|
+
const xMin = origin.x + sinMin * deltaR;
|
23
|
+
const yMin = origin.y - cosMin * deltaR;
|
24
|
+
const xMax = origin.x + sinMax * deltaR;
|
25
|
+
const yMax = origin.y - cosMax * deltaR;
|
26
|
+
if (type === void 0) {
|
27
|
+
const size = 1;
|
28
|
+
tickmarks.push(
|
29
|
+
svg`<rect
|
30
|
+
x=${xMin - size / 2}
|
31
|
+
y=${yMin - size / 2}
|
32
|
+
width=${size}
|
33
|
+
height=${size}
|
34
|
+
fill=${colorName}
|
35
|
+
transform="rotate(${minAngle} ${xMin} ${yMin})"
|
36
|
+
vector-effect="non-scaling-stroke"/>`
|
37
|
+
);
|
38
|
+
tickmarks.push(
|
39
|
+
svg`<rect
|
40
|
+
x=${xMax - size / 2}
|
41
|
+
y=${yMax - size / 2}
|
42
|
+
width=${size}
|
43
|
+
height=${size}
|
44
|
+
fill=${colorName}
|
45
|
+
transform="rotate(${maxAngle} ${xMax} ${yMax})"
|
46
|
+
vector-effect="non-scaling-stroke"/>`
|
47
|
+
);
|
48
|
+
} else {
|
49
|
+
const currentRadius = Math.min(deltaR + tickWidth, radius);
|
50
|
+
const x2Min = origin.x + sinMin * currentRadius;
|
51
|
+
const y2Min = origin.y - cosMin * currentRadius;
|
52
|
+
const x2Max = origin.x + sinMax * currentRadius;
|
53
|
+
const y2Max = origin.y - cosMax * currentRadius;
|
54
|
+
tickmarks.push(
|
55
|
+
svg`<line x1=${xMin} y1=${yMin} x2=${x2Min} y2=${y2Min} stroke=${colorName} stroke-width=${strokeWidth} vector-effect="non-scaling-stroke"/>`
|
56
|
+
);
|
57
|
+
tickmarks.push(
|
58
|
+
svg`<line x1=${xMax} y1=${yMax} x2=${x2Max} y2=${y2Max} stroke=${colorName} stroke-width=${strokeWidth} vector-effect="non-scaling-stroke"/>`
|
59
|
+
);
|
60
|
+
if (currentRadius >= radius)
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
return tickmarks;
|
65
|
+
}
|
66
|
+
export {
|
67
|
+
radialTickmarks
|
68
|
+
};
|
69
|
+
//# sourceMappingURL=radial-tickmark.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"radial-tickmark.js","sources":["../../../src/navigation-instruments/compass/radial-tickmark.ts"],"sourcesContent":["import {SVGTemplateResult, svg} from 'lit';\nimport {TickmarkType, TickmarkStyle, tickmarkColor} from '../watch/tickmark';\n\nexport function radialTickmarks(\n minAngle: number,\n maxAngle: number,\n type: TickmarkType | undefined\n): SVGTemplateResult[] {\n if (type === TickmarkType.main || type === TickmarkType.tertiary) {\n throw new Error(\n 'Only secondary tickmarks or undefined tickmarks (dots) are supported'\n );\n }\n\n const origin = {x: 0, y: 0};\n const radius = 320 / 2;\n const strokeWidth = '1.2';\n const margin = 1.5;\n const colorName = tickmarkColor(TickmarkStyle.hinted);\n const tickWidth = type === TickmarkType.secondary ? 4 : 1;\n const tickmarks: SVGTemplateResult[] = [];\n\n const sinMin = Math.sin((minAngle * Math.PI) / 180);\n const cosMin = Math.cos((minAngle * Math.PI) / 180);\n const sinMax = Math.sin((maxAngle * Math.PI) / 180);\n const cosMax = Math.cos((maxAngle * Math.PI) / 180);\n\n const deltaIncrement = tickWidth * margin;\n\n for (let deltaR = 0; deltaR <= radius; deltaR += deltaIncrement) {\n const xMin = origin.x + sinMin * deltaR;\n const yMin = origin.y - cosMin * deltaR;\n const xMax = origin.x + sinMax * deltaR;\n const yMax = origin.y - cosMax * deltaR;\n\n if (type === undefined) {\n const size = 1;\n tickmarks.push(\n svg`<rect \n x=${xMin - size / 2} \n y=${yMin - size / 2} \n width=${size} \n height=${size} \n fill=${colorName} \n transform=\"rotate(${minAngle} ${xMin} ${yMin})\" \n vector-effect=\"non-scaling-stroke\"/>`\n );\n tickmarks.push(\n svg`<rect \n x=${xMax - size / 2} \n y=${yMax - size / 2} \n width=${size} \n height=${size} \n fill=${colorName} \n transform=\"rotate(${maxAngle} ${xMax} ${yMax})\" \n vector-effect=\"non-scaling-stroke\"/>`\n );\n } else {\n const currentRadius = Math.min(deltaR + tickWidth, radius);\n const x2Min = origin.x + sinMin * currentRadius;\n const y2Min = origin.y - cosMin * currentRadius;\n const x2Max = origin.x + sinMax * currentRadius;\n const y2Max = origin.y - cosMax * currentRadius;\n\n tickmarks.push(\n svg`<line x1=${xMin} y1=${yMin} x2=${x2Min} y2=${y2Min} stroke=${colorName} stroke-width=${strokeWidth} vector-effect=\"non-scaling-stroke\"/>`\n );\n tickmarks.push(\n svg`<line x1=${xMax} y1=${yMax} x2=${x2Max} y2=${y2Max} stroke=${colorName} stroke-width=${strokeWidth} vector-effect=\"non-scaling-stroke\"/>`\n );\n\n if (currentRadius >= radius) break;\n }\n }\n\n return tickmarks;\n}\n"],"names":[],"mappings":";;AAGgB,SAAA,gBACd,UACA,UACA,MACqB;AACrB,MAAI,SAAS,aAAa,QAAQ,SAAS,aAAa,UAAU;AAChE,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,SAAS,EAAC,GAAG,GAAG,GAAG,EAAC;AAC1B,QAAM,SAAS,MAAM;AACrB,QAAM,cAAc;AACpB,QAAM,SAAS;AACT,QAAA,YAAY,cAAc,cAAc,MAAM;AACpD,QAAM,YAAY,SAAS,aAAa,YAAY,IAAI;AACxD,QAAM,YAAiC,CAAA;AAEvC,QAAM,SAAS,KAAK,IAAK,WAAW,KAAK,KAAM,GAAG;AAClD,QAAM,SAAS,KAAK,IAAK,WAAW,KAAK,KAAM,GAAG;AAClD,QAAM,SAAS,KAAK,IAAK,WAAW,KAAK,KAAM,GAAG;AAClD,QAAM,SAAS,KAAK,IAAK,WAAW,KAAK,KAAM,GAAG;AAElD,QAAM,iBAAiB,YAAY;AAEnC,WAAS,SAAS,GAAG,UAAU,QAAQ,UAAU,gBAAgB;AACzD,UAAA,OAAO,OAAO,IAAI,SAAS;AAC3B,UAAA,OAAO,OAAO,IAAI,SAAS;AAC3B,UAAA,OAAO,OAAO,IAAI,SAAS;AAC3B,UAAA,OAAO,OAAO,IAAI,SAAS;AAEjC,QAAI,SAAS,QAAW;AACtB,YAAM,OAAO;AACH,gBAAA;AAAA,QACR;AAAA,cACM,OAAO,OAAO,CAAC;AAAA,cACf,OAAO,OAAO,CAAC;AAAA,kBACX,IAAI;AAAA,mBACH,IAAI;AAAA,iBACN,SAAS;AAAA,8BACI,QAAQ,IAAI,IAAI,IAAI,IAAI;AAAA;AAAA,MAAA;AAGtC,gBAAA;AAAA,QACR;AAAA,cACM,OAAO,OAAO,CAAC;AAAA,cACf,OAAO,OAAO,CAAC;AAAA,kBACX,IAAI;AAAA,mBACH,IAAI;AAAA,iBACN,SAAS;AAAA,8BACI,QAAQ,IAAI,IAAI,IAAI,IAAI;AAAA;AAAA,MAAA;AAAA,IAEhD,OACK;AACL,YAAM,gBAAgB,KAAK,IAAI,SAAS,WAAW,MAAM;AACnD,YAAA,QAAQ,OAAO,IAAI,SAAS;AAC5B,YAAA,QAAQ,OAAO,IAAI,SAAS;AAC5B,YAAA,QAAQ,OAAO,IAAI,SAAS;AAC5B,YAAA,QAAQ,OAAO,IAAI,SAAS;AAExB,gBAAA;AAAA,QACR,eAAe,IAAI,OAAO,IAAI,OAAO,KAAK,OAAO,KAAK,WAAW,SAAS,iBAAiB,WAAW;AAAA,MAAA;AAE9F,gBAAA;AAAA,QACR,eAAe,IAAI,OAAO,IAAI,OAAO,KAAK,OAAO,KAAK,WAAW,SAAS,iBAAiB,WAAW;AAAA,MAAA;AAGxG,UAAI,iBAAiB;AAAQ;AAAA,IAC/B;AAAA,EACF;AAEO,SAAA;AACT;"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { css } from "lit";
|
2
|
+
const componentStyle = css`* {
|
3
|
+
box-sizing: border-box;
|
4
|
+
}
|
5
|
+
|
6
|
+
.container {
|
7
|
+
position: relative;
|
8
|
+
width: 100%;
|
9
|
+
height: 100%;
|
10
|
+
}
|
11
|
+
|
12
|
+
.container > * {
|
13
|
+
position: absolute;
|
14
|
+
top: 0;
|
15
|
+
left: 0;
|
16
|
+
width: 100%;
|
17
|
+
height: 100%;
|
18
|
+
}
|
19
|
+
|
20
|
+
:host {
|
21
|
+
display: block;
|
22
|
+
width: 100%;
|
23
|
+
height: 100%;
|
24
|
+
}
|
25
|
+
`;
|
26
|
+
export {
|
27
|
+
componentStyle as default
|
28
|
+
};
|
29
|
+
//# sourceMappingURL=compass-flat.css.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"compass-flat.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { LitElement } from 'lit';
|
2
|
+
import '../watch-flat/watch-flat';
|
3
|
+
export declare enum LabelPosition {
|
4
|
+
top = -45,
|
5
|
+
bottom = 50
|
6
|
+
}
|
7
|
+
export declare enum LabelStyle {
|
8
|
+
regular = "var(--instrument-tick-mark-secondary-color)"
|
9
|
+
}
|
10
|
+
export interface Label {
|
11
|
+
x: number;
|
12
|
+
y: LabelPosition;
|
13
|
+
text: string;
|
14
|
+
}
|
15
|
+
export declare class ObcCompassFlat extends LitElement {
|
16
|
+
noPadding: boolean;
|
17
|
+
FOVIndicator: boolean;
|
18
|
+
padding: number;
|
19
|
+
heading: number;
|
20
|
+
courseOverGround: number;
|
21
|
+
tickInterval: number;
|
22
|
+
FOV: number;
|
23
|
+
minFOV: number;
|
24
|
+
maxFOV: number;
|
25
|
+
labels: Label[];
|
26
|
+
containerWidth: number;
|
27
|
+
private resizeObserver;
|
28
|
+
connectedCallback(): void;
|
29
|
+
disconnectedCallback(): void;
|
30
|
+
private updateLabels;
|
31
|
+
private generateIntervalTickmarks;
|
32
|
+
private generateCardinalTickmarks;
|
33
|
+
private generateTickmarks;
|
34
|
+
private renderFOVIndicator;
|
35
|
+
private get HDGSvg();
|
36
|
+
private COGSvg;
|
37
|
+
render(): import("lit-html").TemplateResult<2>;
|
38
|
+
static styles: import("lit").CSSResult;
|
39
|
+
}
|
40
|
+
declare global {
|
41
|
+
interface HTMLElementTagNameMap {
|
42
|
+
'obc-compass-flat': ObcCompassFlat;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
//# sourceMappingURL=compass-flat.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"compass-flat.d.ts","sourceRoot":"","sources":["../../../src/navigation-instruments/compass-flat/compass-flat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAoC,MAAM,KAAK,CAAC;AAIlE,OAAO,0BAA0B,CAAC;AAElC,oBAAY,aAAa;IACvB,GAAG,MAAM;IACT,MAAM,KAAK;CACZ;AAED,oBAAY,UAAU;IACpB,OAAO,gDAAgD;CACxD;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,aAAa,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBACa,cAAe,SAAQ,UAAU;IACjB,SAAS,EAAE,OAAO,CAAQ;IAC1B,YAAY,EAAE,OAAO,CAAS;IAC/B,OAAO,EAAE,MAAM,CAAM;IACrB,OAAO,SAAK;IACZ,gBAAgB,SAAK;IACrB,YAAY,SAAK;IACjB,GAAG,SAAM;IACT,MAAM,SAAM;IACZ,MAAM,SAAO;IACvC,MAAM,EAAE,KAAK,EAAE,CAAM;IAEK,cAAc,SAAK;IAE7C,OAAO,CAAC,cAAc,CAKnB;IAEM,iBAAiB;IAKjB,oBAAoB;IAK7B,OAAO,CAAC,YAAY;IAsCpB,OAAO,CAAC,yBAAyB;IAwBjC,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,KAAK,MAAM,GAIjB;IAED,OAAO,CAAC,MAAM;IAQL,MAAM;IAgCf,OAAgB,MAAM,0BAA6B;CACpD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;KACpC;CACF"}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
import { unsafeCSS, LitElement, svg } from "lit";
|
2
|
+
import componentStyle from "./compass-flat.css.js";
|
3
|
+
import { property, customElement } from "lit/decorators.js";
|
4
|
+
import { TickmarkType } from "../watch-flat/tickmark-flat.js";
|
5
|
+
import "../watch-flat/watch-flat.js";
|
6
|
+
var __defProp = Object.defineProperty;
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
8
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
9
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
10
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
11
|
+
if (decorator = decorators[i])
|
12
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
13
|
+
if (kind && result)
|
14
|
+
__defProp(target, key, result);
|
15
|
+
return result;
|
16
|
+
};
|
17
|
+
var LabelPosition = /* @__PURE__ */ ((LabelPosition2) => {
|
18
|
+
LabelPosition2[LabelPosition2["top"] = -45] = "top";
|
19
|
+
LabelPosition2[LabelPosition2["bottom"] = 50] = "bottom";
|
20
|
+
return LabelPosition2;
|
21
|
+
})(LabelPosition || {});
|
22
|
+
var LabelStyle = /* @__PURE__ */ ((LabelStyle2) => {
|
23
|
+
LabelStyle2["regular"] = "var(--instrument-tick-mark-secondary-color)";
|
24
|
+
return LabelStyle2;
|
25
|
+
})(LabelStyle || {});
|
26
|
+
let ObcCompassFlat = class extends LitElement {
|
27
|
+
constructor() {
|
28
|
+
super(...arguments);
|
29
|
+
this.noPadding = true;
|
30
|
+
this.FOVIndicator = false;
|
31
|
+
this.padding = 16;
|
32
|
+
this.heading = 0;
|
33
|
+
this.courseOverGround = 0;
|
34
|
+
this.tickInterval = 5;
|
35
|
+
this.FOV = 45;
|
36
|
+
this.minFOV = 45;
|
37
|
+
this.maxFOV = 180;
|
38
|
+
this.labels = [];
|
39
|
+
this.containerWidth = 0;
|
40
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
41
|
+
for (const entry of entries) {
|
42
|
+
this.containerWidth = entry.contentRect.width;
|
43
|
+
this.updateLabels();
|
44
|
+
}
|
45
|
+
});
|
46
|
+
}
|
47
|
+
connectedCallback() {
|
48
|
+
super.connectedCallback();
|
49
|
+
this.resizeObserver.observe(this);
|
50
|
+
}
|
51
|
+
disconnectedCallback() {
|
52
|
+
super.disconnectedCallback();
|
53
|
+
this.resizeObserver.unobserve(this);
|
54
|
+
}
|
55
|
+
updateLabels() {
|
56
|
+
if (this.containerWidth < 192) {
|
57
|
+
this.labels = [];
|
58
|
+
} else if (this.containerWidth <= 300) {
|
59
|
+
this.labels = [
|
60
|
+
{ x: -180, y: -45, text: "S" },
|
61
|
+
{ x: -90, y: -45, text: "W" },
|
62
|
+
{ x: 0, y: -45, text: "N" },
|
63
|
+
{ x: 90, y: -45, text: "E" },
|
64
|
+
{ x: 180, y: -45, text: "S" },
|
65
|
+
{ x: 270, y: -45, text: "W" },
|
66
|
+
{ x: 360, y: -45, text: "N" },
|
67
|
+
{ x: 450, y: -45, text: "E" },
|
68
|
+
{ x: 540, y: -45, text: "S" }
|
69
|
+
];
|
70
|
+
} else {
|
71
|
+
this.labels = [
|
72
|
+
{ x: -180, y: -45, text: "S" },
|
73
|
+
{ x: -135, y: -45, text: "SW" },
|
74
|
+
{ x: -90, y: -45, text: "W" },
|
75
|
+
{ x: -45, y: -45, text: "NW" },
|
76
|
+
{ x: 0, y: -45, text: "N" },
|
77
|
+
{ x: 45, y: -45, text: "NE" },
|
78
|
+
{ x: 90, y: -45, text: "E" },
|
79
|
+
{ x: 135, y: -45, text: "SE" },
|
80
|
+
{ x: 180, y: -45, text: "S" },
|
81
|
+
{ x: 225, y: -45, text: "SW" },
|
82
|
+
{ x: 270, y: -45, text: "W" },
|
83
|
+
{ x: 315, y: -45, text: "NW" },
|
84
|
+
{ x: 360, y: -45, text: "N" },
|
85
|
+
{ x: 405, y: -45, text: "NE" },
|
86
|
+
{ x: 450, y: -45, text: "E" },
|
87
|
+
{ x: 495, y: -45, text: "SE" },
|
88
|
+
{ x: 540, y: -45, text: "S" }
|
89
|
+
];
|
90
|
+
}
|
91
|
+
}
|
92
|
+
generateIntervalTickmarks(scale) {
|
93
|
+
const tickmarks = [];
|
94
|
+
let cardinalInterval = 90;
|
95
|
+
if (this.containerWidth > 300) {
|
96
|
+
cardinalInterval = 45;
|
97
|
+
} else if (this.containerWidth < 192) {
|
98
|
+
cardinalInterval = 0;
|
99
|
+
}
|
100
|
+
for (let angle = -180; angle < this.maxFOV * 3; angle += this.tickInterval) {
|
101
|
+
if (cardinalInterval !== 0 && angle % cardinalInterval === 0) {
|
102
|
+
continue;
|
103
|
+
}
|
104
|
+
tickmarks.push({ angle: angle * scale, type: TickmarkType.secondary });
|
105
|
+
}
|
106
|
+
return tickmarks;
|
107
|
+
}
|
108
|
+
generateCardinalTickmarks(scale) {
|
109
|
+
const tickmarks = [];
|
110
|
+
for (const label of this.labels) {
|
111
|
+
tickmarks.push({ angle: label.x * scale, type: TickmarkType.main });
|
112
|
+
}
|
113
|
+
return tickmarks;
|
114
|
+
}
|
115
|
+
generateTickmarks(scale) {
|
116
|
+
return [
|
117
|
+
...this.generateCardinalTickmarks(scale),
|
118
|
+
...this.generateIntervalTickmarks(scale)
|
119
|
+
];
|
120
|
+
}
|
121
|
+
renderFOVIndicator() {
|
122
|
+
const indicators = [];
|
123
|
+
const maxAdjustment = 10;
|
124
|
+
const minContainerWidth = 300;
|
125
|
+
const maxContainerWidth = 512;
|
126
|
+
let yAdjustment = 0;
|
127
|
+
if (this.containerWidth < maxContainerWidth) {
|
128
|
+
const widthRange = maxContainerWidth - minContainerWidth;
|
129
|
+
const scaleFactor = (maxContainerWidth - this.containerWidth) / widthRange;
|
130
|
+
yAdjustment = scaleFactor * maxAdjustment;
|
131
|
+
}
|
132
|
+
const y = 50 + yAdjustment;
|
133
|
+
indicators.push(svg`
|
134
|
+
<text x="-175" y=${y} class="label left" fill=${"var(--instrument-tick-mark-secondary-color)"}>
|
135
|
+
${-this.FOV}\u00B0
|
136
|
+
</text>`);
|
137
|
+
indicators.push(svg`
|
138
|
+
<text x="0" y=${y} class="label" fill=${"var(--instrument-tick-mark-secondary-color)"}>
|
139
|
+
${this.heading}\u00B0
|
140
|
+
</text>`);
|
141
|
+
indicators.push(svg`
|
142
|
+
<text x="175" y=${y} class="label right" fill=${"var(--instrument-tick-mark-secondary-color)"}>
|
143
|
+
${this.FOV}\u00B0
|
144
|
+
</text>`);
|
145
|
+
return indicators;
|
146
|
+
}
|
147
|
+
get HDGSvg() {
|
148
|
+
return svg`<g transform="translate(-24, -74)">
|
149
|
+
<path d="M36.7011 44.1445L36.6898 44.1379L36.6781 44.1318L24.2301 37.6823L24.0001 37.5631L23.7701 37.6823L11.3221 44.1318L11.3104 44.1379L11.2991 44.1445C9.25497 45.3438 6.78661 43.308 7.68828 41.0919L22.6036 4.43285C23.1096 3.18905 24.8906 3.18905 25.3967 4.43284L40.3119 41.0919C41.2136 43.308 38.7452 45.3438 36.7011 44.1445Z" fill="var(--instrument-enhanced-secondary-color)" stroke="var(--border-silhouette-color)"/>
|
150
|
+
</g>`;
|
151
|
+
}
|
152
|
+
COGSvg(translation) {
|
153
|
+
return svg`
|
154
|
+
<g transform="translate(${-24 + translation}, -74)">
|
155
|
+
<path d="M31.9025 36.0262L33.1068 36.6502L32.5956 35.3938L24.4632 15.406L24.0001 14.2677L23.537 15.406L15.4046 35.3938L14.8935 36.6502L16.0978 36.0262L24.0001 31.9319L31.9025 36.0262ZM36.7011 44.1445L36.6898 44.1379L36.6781 44.1318L24.2301 37.6823L24.0001 37.5631L23.7701 37.6823L11.3221 44.1318L11.3104 44.1379L11.2991 44.1445C9.25497 45.3438 6.78661 43.308 7.68828 41.0919L22.6036 4.43285C23.1096 3.18905 24.8906 3.18905 25.3967 4.43284L40.3119 41.0919C41.2136 43.308 38.7452 45.3438 36.7011 44.1445Z" fill="var(--instrument-enhanced-secondary-color)" stroke="var(--border-silhouette-color)"/>
|
156
|
+
</g>
|
157
|
+
`;
|
158
|
+
}
|
159
|
+
render() {
|
160
|
+
let angleDiff = this.courseOverGround - this.heading;
|
161
|
+
if (angleDiff > this.maxFOV) {
|
162
|
+
angleDiff -= 360;
|
163
|
+
} else if (angleDiff < -this.maxFOV) {
|
164
|
+
angleDiff += 360;
|
165
|
+
}
|
166
|
+
this.FOV = Math.max(this.minFOV, Math.abs(angleDiff));
|
167
|
+
const baseOffset = 5;
|
168
|
+
const translationScale = baseOffset * 35 / this.FOV;
|
169
|
+
const translation = angleDiff * translationScale;
|
170
|
+
const tickmarks = this.generateTickmarks(translationScale);
|
171
|
+
this.labels.map((l) => {
|
172
|
+
l.x = l.x * translationScale;
|
173
|
+
});
|
174
|
+
const viewBox = this.noPadding ? "-192 -128 384 128" : "-200 -144 400 144";
|
175
|
+
return svg`
|
176
|
+
<div class="container">
|
177
|
+
<obc-watch-flat .noPadding=${this.noPadding} .FOVIndicator=${this.FOVIndicator ? this.renderFOVIndicator() : []} .labels=${this.labels} .rotation=${this.heading} .tickmarks=${tickmarks} .tickmarkSpacing=${translationScale}></obc-watch-flat>
|
178
|
+
<svg viewBox=${viewBox} xmlns="http://www.w3.org/2000/svg">
|
179
|
+
${this.HDGSvg}${this.COGSvg(translation)}
|
180
|
+
</div>
|
181
|
+
`;
|
182
|
+
}
|
183
|
+
};
|
184
|
+
ObcCompassFlat.styles = unsafeCSS(componentStyle);
|
185
|
+
__decorateClass([
|
186
|
+
property({ type: Boolean })
|
187
|
+
], ObcCompassFlat.prototype, "noPadding", 2);
|
188
|
+
__decorateClass([
|
189
|
+
property({ type: Boolean })
|
190
|
+
], ObcCompassFlat.prototype, "FOVIndicator", 2);
|
191
|
+
__decorateClass([
|
192
|
+
property({ type: Number })
|
193
|
+
], ObcCompassFlat.prototype, "padding", 2);
|
194
|
+
__decorateClass([
|
195
|
+
property({ type: Number })
|
196
|
+
], ObcCompassFlat.prototype, "heading", 2);
|
197
|
+
__decorateClass([
|
198
|
+
property({ type: Number })
|
199
|
+
], ObcCompassFlat.prototype, "courseOverGround", 2);
|
200
|
+
__decorateClass([
|
201
|
+
property({ type: Number })
|
202
|
+
], ObcCompassFlat.prototype, "tickInterval", 2);
|
203
|
+
__decorateClass([
|
204
|
+
property({ type: Number })
|
205
|
+
], ObcCompassFlat.prototype, "FOV", 2);
|
206
|
+
__decorateClass([
|
207
|
+
property({ type: Number })
|
208
|
+
], ObcCompassFlat.prototype, "minFOV", 2);
|
209
|
+
__decorateClass([
|
210
|
+
property({ type: Number })
|
211
|
+
], ObcCompassFlat.prototype, "maxFOV", 2);
|
212
|
+
__decorateClass([
|
213
|
+
property({ type: Number })
|
214
|
+
], ObcCompassFlat.prototype, "containerWidth", 2);
|
215
|
+
ObcCompassFlat = __decorateClass([
|
216
|
+
customElement("obc-compass-flat")
|
217
|
+
], ObcCompassFlat);
|
218
|
+
export {
|
219
|
+
LabelPosition,
|
220
|
+
LabelStyle,
|
221
|
+
ObcCompassFlat
|
222
|
+
};
|
223
|
+
//# sourceMappingURL=compass-flat.js.map
|