Add right and bottom positioning of compass

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2026-05-25 18:04:43 -07:00
parent fb206279a3
commit 9bdb91992c

View File

@@ -133,8 +133,19 @@ class AnnotationHandler extends CodeContentHandler {
$viewLabels = self::getCompassLabels($metadata['view']['direction'], $metadata['view']['rostral']);
$rotate = $metadata['view']['rotate'] ?? 0;
$textRotate = $rotate * -1;
$compSize = $metadata['view']['size'] ?? 25;
if (isset($metadata['view']['right'])) {
$compX = ($baseWidth / $fixScale) - $metadata['view']['right'] - $compSize;
} else {
$compX = $metadata['view']['left'] ?? 1;
}
if (isset($metadata['view']['bottom'])) {
$compY = ($baseHeight / $fixScale) - $metadata['view']['bottom'] - $compSize;
} else {
$compY = $metadata['view']['top'] ?? 1;
}
$elCompass = <<<comp
<symbol id="compass$svgID" viewBox="0 0 100 100" preserveAspectRatio="xMinYMin meet" refX="left" refY="top" style="font-family:'TeX Gyre DejaVu Math';font-size:11.686px;letter-spacing:0px;line-height:125%;text-align:center;text-anchor:middle;word-spacing:0px">
<symbol id="compass$svgID" viewBox="0 0 100 100" preserveAspectRatio="xMinYMin meet" style="font-family:'TeX Gyre DejaVu Math';font-size:11.686px;letter-spacing:0px;line-height:125%;text-align:center;text-anchor:middle;word-spacing:0px">
<circle cx="50" cy="50" r="50" style="fill-opacity:.35;fill:#ffffff;"></circle>
<path d="M 50,81.3 41.4,58.6 18.7,50 41.4,41.4 50,18.7 58.6,41.4 81.3,50 58.6,58.6 Z" style="fill:#000000;stroke-width:1.5;stroke:#000000"></path>
<path d="m50 81.3 -8.6 -22.6 0 -8.6 -22.6 0 22.6 -8.6 8.6 0 0 -22.6 8.6 22.6 0 8.6 22.6 0 -22.6 8.6 -8.6 0z" style="fill:#ffffff;stroke-width:1.5025"></path>
@@ -147,18 +158,15 @@ class AnnotationHandler extends CodeContentHandler {
</symbol>
comp;
//TODO: Right and Bottom and/or negative positioning
$compLeft = $metadata['view']['left'] ?? 0;
$compTop = $metadata['view']['top'] ?? 0;
$compRotX = $compLeft + (($metadata['view']['size'] ?? 25) * .5);
$compRotY = $compTop + (($metadata['view']['size'] ?? 25) * .5);
$compRotX = $compX + ($compSize * .5);
$compRotY = $compY + ($compSize * .5);
$attrCompass = array(
'href'=> "#compass" . $svgID,
'transform' => "scale( $fixScale ) rotate( $rotate $compRotX $compRotY)",
'x' => $compLeft,
'y' => $compTop,
'width' => $metadata['view']['size'] ?? 25,
'height' => $metadata['view']['size'] ?? 25,
'x' => $compX,
'y' => $compY,
'width' => $compSize,
'height' => $compSize,
'style' => "transform-box: fill-box;"
);
$useCompass = Html::rawElement('use', $attrCompass);