import type { CSSProperties } from 'react';
export interface MarkersProps {
size: number;
style?: CSSProperties;
}
const halfPi = Math.PI / 2;
const twoPi = Math.PI * 2;
export function Circle({ style, size }: MarkersProps) {
return ;
}
export function Square({ style, size }: MarkersProps) {
const x = size / 2;
return ;
}
export function Diamond({ size, style }: MarkersProps) {
const x = size / 2;
return ;
}
export function Triangle({ style, size }: MarkersProps) {
const height = (Math.sqrt(3) * size) / 2;
const x = size / 2;
return (
);
}
export function Cross({ size, style }: MarkersProps) {
const x = size / 2;
return (
);
}
export function XMark(props: MarkersProps) {
return (
);
}
export function Pentagon({ style, size }: MarkersProps) {
return (
);
}
export function Star({ style, size }: MarkersProps) {
const ext = Array.from(getPolyPoints(size, 5, 0));
const int = Array.from(getPolyPoints(size / 2.5, 5, (2 * Math.PI) / 10));
const points: string[] = [];
for (let i = 0; i < ext.length; i++) {
points.push(ext[i], int[i]);
}
return ;
}
export function Hexagon({ style, size }: MarkersProps) {
return (
);
}
/**
* https://math.stackexchange.com/a/3582355
*/
function* getPolyPoints(diameter: number, k: number, angle = 0) {
const r = diameter / 2;
for (let i = 0; i < k; i++) {
const calculation = (twoPi * i) / k - halfPi + angle;
const x = r * Math.cos(calculation);
const y = r * Math.sin(calculation);
yield `${x},${y}`;
}
}