import Konva from "konva"; import { Circle, Line, Rect } from "react-konva"; import { useMapHeight, useMapWidth, } from "../../contexts/MapInteractionContext"; import colors from "../../helpers/colors"; import { scaleAndFlattenPoints } from "../../helpers/konva"; import Vector2 from "../../helpers/Vector2"; import { Drawing as DrawingType } from "../../types/Drawing"; type DrawingProps = { drawing: DrawingType; } & Konva.ShapeConfig; function Drawing({ drawing, ...props }: DrawingProps) { const mapWidth = useMapWidth(); const mapHeight = useMapHeight(); const mapSize = new Vector2(mapWidth, mapHeight); const defaultProps = { fill: colors[drawing.color] || drawing.color, stroke: colors[drawing.color] || drawing.color, opacity: drawing.blend ? 0.5 : 1, id: drawing.id, }; if (drawing.type === "path") { return ( ); } else if (drawing.type === "shape") { if (drawing.shapeType === "rectangle") { return ( ); } else if (drawing.shapeType === "circle") { const minSide = mapWidth < mapHeight ? mapWidth : mapHeight; return ( ); } else if (drawing.shapeType === "triangle") { return ( ); } else if (drawing.shapeType === "line") { return ( ); } } return null; } export default Drawing;