import { Position } from "../types"; import { Circle } from "./circle"; import { Rectangle } from "./rectangle"; import { Triangle } from "./triangle"; export declare type Shape = Triangle | Rectangle | Circle; export declare const serializeShape: (shape: Shape) => unknown; export declare const deserializeShape: (serializedShape: unknown) => Shape | undefined; export declare const getRandomPositionInsideShape: (shape: Shape) => Position; export declare const getRandomPositionOnEdge: (shape: Shape) => Position; export declare const shapeContainsPosition: (shape: Shape, position: Position) => boolean; /** * Interface for describing the implementation of a single shape. * * Each shape in the library should be able to accomplish same purposes than all other shapes, for example currently: * - Finding a random position inside the shape. * - Checking if a position is inside the shape. * * The logic is intentionally kept separate from the data structure of a shape for simplifying serialization * (shape data structure can be serialized as is as long as it doesn't contain any logic) */ export interface ShapeLogicImplementation { /** * Get unbiased random position within the Shape. * @return Random position within the Shape. */ getRandomPosition(shape: ShapeType): Position; /** * Get random position on the Shape edges. * @return Random position within the Shape's edges. */ getRandomEdgePosition(shape: ShapeType): Position; /** * Check whether a position is within the Shape or not. * @param position Position to check. * @return `true` if `position` is inside the shape, otherwise `false`. */ containsPosition(shape: ShapeType, position: Position): boolean; }