Terrain: the cars redrawn (a rear view on its tyres with the back window, a side view on two round wheels with two windows, the wheels apart from the body); every row of the panel a cell as on the artboard, what a bigger screen adds goes to a blank row above the buttons instead of stretching the fields and the elevation; the dials' data-key renamed data-dial (the keys took it for a binding and drew an empty label)
This commit is contained in:
1 parent
1ee79fff66
commit
21ad6c0c21
2 files changed
+27
-13
No files matched your search
@@ -357,8 +357,16 @@ const ACROSS_AT_M = 50; // the side slope this far ahead, over ±ACROSS_HALF_M
|
||||
const ACROSS_HALF_M = 15;
|
||||
const AHEAD_EVERY_MS = 2000; // DEM lookups at most this often
|
||||
const CARDINALS = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
||||
const CAR_REAR = "M-46 30 L-46 -4 L-34 -34 L34 -34 L46 -4 L46 30 Z M-50 30 h22 v12 h-22 Z M28 30 h22 v12 h-22 Z";
|
||||
const CAR_SIDE = "M-62 26 L-62 -2 L-30 -6 L-18 -30 L40 -30 L52 -4 L62 -2 L62 26 Z";
|
||||
// The cars stand on the ground line (y 30) and turn about its middle: body
|
||||
// with the windows cut out (evenodd), wheels drawn over it with a gap round them.
|
||||
const CAR_REAR = {
|
||||
body: "M-54 10 L-54 -14 L-44 -18 L-34 -46 L34 -46 L44 -18 L54 -14 L54 10 Z M-27 -40 L-23 -24 L23 -24 L27 -40 Z",
|
||||
wheels: "M-50 30 V4 h20 V30 Z M30 30 V4 h20 V30 Z",
|
||||
};
|
||||
const CAR_SIDE = {
|
||||
body: "M-64 14 L-64 -10 L-34 -14 L-20 -42 L34 -42 L46 -14 L64 -10 L64 14 Z M-16 -36 L-24 -18 L4 -18 L4 -36 Z M10 -36 L10 -18 L38 -18 L30 -36 Z",
|
||||
wheels: "M-52 16 a14 14 0 1 0 28 0 a14 14 0 1 0 -28 0 Z M26 16 a14 14 0 1 0 28 0 a14 14 0 1 0 -28 0 Z",
|
||||
};
|
||||
const dialPoint = (a) => { const r = ((a - 90) * Math.PI) / 180; return `${(120 * Math.cos(r)).toFixed(1)} ${(30 + 120 * Math.sin(r)).toFixed(1)}`; };
|
||||
const arc = (a, b, cls) => `<path class="${cls}" d="M${dialPoint(a)} A120 120 0 0 1 ${dialPoint(b)}"/>`;
|
||||
const severity = (key, v) => (v == null ? "" : Math.abs(v) >= WARN[key] * 1.5 ? "drive-cell--warn" : Math.abs(v) >= WARN[key] ? "drive-terrain--caution" : "");
|
||||
@@ -367,12 +375,13 @@ const offset = ([lon, lat], bearing, m) => [lon + (m * Math.sin(bearing * RAD))
|
||||
|
||||
export function terrainMenu(ctx) {
|
||||
const el = panel("drive-terrain", "Terrain", `
|
||||
<div class="drive-panel__cell drive-terrain__dial" data-key="roll"></div>
|
||||
<div class="drive-panel__cell drive-terrain__dial" data-key="pitch"></div>
|
||||
<div class="drive-panel__cell drive-terrain__dial" data-dial="roll"></div>
|
||||
<div class="drive-panel__cell drive-terrain__dial" data-dial="pitch"></div>
|
||||
<div class="drive-panel__cell drive-terrain__field" data-field="heading"></div>
|
||||
<div class="drive-panel__cell drive-terrain__field" data-field="climb"></div>
|
||||
<div class="drive-panel__cell drive-terrain__field" data-field="across"></div>
|
||||
<div class="drive-panel__cell drive-terrain__elevation"></div>
|
||||
<div class="drive-panel__cell drive-terrain__spare"></div>
|
||||
<button type="button" class="drive-terrain__level" data-action="level">Level here (zero)</button>
|
||||
<button type="button" class="drive-terrain__reset" data-action="reset">Reset max</button>
|
||||
<button type="button" class="drive-terrain__road" data-action="road">Road view</button>`);
|
||||
@@ -407,7 +416,7 @@ export function terrainMenu(ctx) {
|
||||
${arc(-w, w, "drive-terrain__ok")}${arc(-w * 1.5, -w, "drive-terrain__amber")}${arc(w, w * 1.5, "drive-terrain__amber")}
|
||||
${arc(-DIAL_MAX, -w * 1.5, "drive-terrain__red")}${arc(w * 1.5, DIAL_MAX, "drive-terrain__red")}
|
||||
<line class="drive-terrain__ground" x1="-130" y1="30" x2="130" y2="30"/>
|
||||
<g transform="rotate(${angle} 0 30)"><line class="drive-terrain__mast" x1="0" y1="30" x2="0" y2="-100"/><path class="drive-terrain__car" d="${key === "roll" ? CAR_REAR : CAR_SIDE}"/></g>${mark}
|
||||
<g transform="rotate(${angle} 0 30)"><line class="drive-terrain__mast" x1="0" y1="30" x2="0" y2="-100"/><path class="drive-terrain__car" fill-rule="evenodd" d="${(key === "roll" ? CAR_REAR : CAR_SIDE).body}"/><path class="drive-terrain__car drive-terrain__wheel" d="${(key === "roll" ? CAR_REAR : CAR_SIDE).wheels}"/></g>${mark}
|
||||
</svg>
|
||||
<span class="drive-terrain__value ${severity(key, value)}">${value == null ? "—" : `${sign(Math.round(value))}${Math.abs(Math.round(value))}°`}</span>
|
||||
<span class="drive-cell__label">${key} · max ${p == null ? "—" : `${Math.abs(Math.round(p))}°`}</span>`;
|
||||
@@ -421,7 +430,7 @@ export function terrainMenu(ctx) {
|
||||
const v = dash?.values || {};
|
||||
for (const key of ["roll", "pitch"]) {
|
||||
if (v[key] != null && (peak[key] == null || Math.abs(v[key]) > Math.abs(peak[key]))) peak[key] = v[key];
|
||||
el.querySelector(`[data-key="${key}"]`).innerHTML = dial(key, v[key]);
|
||||
el.querySelector(`[data-dial="${key}"]`).innerHTML = dial(key, v[key]);
|
||||
}
|
||||
const h = dash?.heading;
|
||||
const deg = h ? Math.round(h.deg) % 360 : null;
|
||||
|
||||
Reference in new issue
Block a user