import { degToRad } from '../../../utils/common' ; import { PointShape , TextureShape } from '../../../utils/themes/theme' ; internal export type SVGPath = string ; internal export type SVGPathFn = ( radius : number ) => SVGPath ; const cross = ( r ) => { return `M ${ - r } 0 L ${ r } 0 M 0 ${ r } L 0 ${ - r }` ; } ; const triangle = ( r ) => { const h = ( r * Math . sqrt ( 3 ) ) / 2 ; const hr = r / 2 ; return `M ${ - h } ${ hr } L ${ h } ${ hr } L 0 ${ - r } Z` ; } ; /**
 * Returns shape function based on rotation of square in degrees
 */ const square = ( rotation = 0 ) : SVGPathFn => ( r ) => { const d = degToRad ( rotation ) ; const s = Math . abs ( Math . cos ( d ) + Math . sin ( d ) ) ; const sr = s > 0 ? r / s : r ; return `M ${ - sr } ${ - sr } L ${ - sr } ${ sr } L ${ sr } ${ sr } L ${ sr } ${ - sr } Z` ; } ; const circle = ( r ) => { return `M ${ - r } 0 a ${ r },${ r } 0 1,0 ${ r * 2 },0 a ${ r },${ r } 0 1,0 ${ - r * 2 },0` ; } ; const line = ( r ) => { return `M 0 ${ - r } l 0 ${ r * 2 }` ; } ; internal export const ShapeRendererFn = { [ PointShape . Circle ] : [ circle , 0 ] , [ PointShape . X ] : [ cross , 45 ] , [ PointShape . Plus ] : [ cross , 0 ] , [ PointShape . Diamond ] : [ square ( 45 ) , 45 ] , [ PointShape . Square ] : [ square ( 0 ) , 0 ] , [ PointShape . Triangle ] : [ triangle , 0 ] , } ; internal export const TextureRendererFn = { ... ShapeRendererFn , [ TextureShape . Line ] : [ line , 0 ] , } ;