Add basic annotation markers

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2026-05-19 16:37:27 -07:00
parent 9f3b4743a9
commit 06f0fd3120

View File

@@ -125,7 +125,40 @@ class AnnotationHandler extends CodeContentHandler {
$attrSvg['height'] = $this->parameters['height']; $attrSvg['height'] = $this->parameters['height'];
} }
return Html::rawElement('svg', $attrSvg, $elBaseImg); if (isset($metadata['annotation'])) {
$markers = [];
$maskCircles = [];
foreach($metadata['annotation'] as $label => $annot) {
if (isset($annot['position'])) {
$attrMask = array(
'cx' => $annot['position']['0'],
'cy' => $annot['position']['1'],
'r' => '3.75',
'fill' => 'black'
);
$maskCirc = Html::rawElement('circle',$attrMask);
array_push($maskCircles,$maskCirc);
$attrMarkerCirc = array(
'cx' => $annot['position']['0'],
'cy' => $annot['position']['1'],
'r' => '3.75',
'style' => 'fill-opacity: .35; stroke-linejoin: bevel; stroke-width: .3793; stroke: #ff0000;',
'fill' => (isset($annot['light']) && $annot['light']) ? 'white' : 'balck'
);
$markCirc = Html::rawElement('circle',$attrMarkerCirc);
array_push($markers,$markCirc);
$attrMarkerText = array(
'x' => $annot['position']['0'],
'y' => $annot['position']['1'],
'style' => 'fill: #ff0000; font-size: 5px; stroke-linejoin: bevel; stroke-width: .6968; text-align: center; text-anchor: middle; transform: translateY(1.5px);'
);
$markText = Html::rawElement('text',$attrMarkerText, isset($annot['label']) ? $annot['label'] : $label );
array_push($markers,$markText);
}
}
}
return Html::rawElement('svg', $attrSvg, $elBaseImg . implode($markers) );
} }
/** /**