Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 23x 23x 23x 23x 23x 23x 23x 23x 14x 14x 9x 9x 9x | import type { Types } from '@cornerstonejs/core';
import { SVGDrawingHelper } from '../types';
import _getHash from './_getHash';
import _setAttributesIfNecessary from './_setAttributesIfNecessary';
import _setNewAttributesIfValid from './_setNewAttributesIfValid';
function drawCircle(
svgDrawingHelper: SVGDrawingHelper,
annotationUID: string,
circleUID: string,
center: Types.Point2,
radius: number,
options = {}
): void {
const { color, fill, width, lineWidth } = Object.assign(
{
color: 'dodgerblue',
fill: 'transparent',
width: '2',
lineWidth: undefined,
},
options
);
// for supporting both lineWidth and width options
const strokeWidth = lineWidth || width;
// variable for the namespace
const svgns = 'http://www.w3.org/2000/svg';
const svgNodeHash = _getHash(annotationUID, 'circle', circleUID);
const existingCircleElement = svgDrawingHelper.getSvgNode(svgNodeHash);
const attributes = {
cx: `${center[0]}`,
cy: `${center[1]}`,
r: `${radius}`,
stroke: color,
fill,
'stroke-width': strokeWidth,
};
if (existingCircleElement) {
_setAttributesIfNecessary(attributes, existingCircleElement);
svgDrawingHelper.setNodeTouched(svgNodeHash);
} else {
const newCircleElement = document.createElementNS(svgns, 'circle');
_setNewAttributesIfValid(attributes, newCircleElement);
svgDrawingHelper.appendNode(newCircleElement, svgNodeHash);
}
}
export default drawCircle;
|