UNPKG

@gorpacrate/core-graphics

Version:

A core library for creating shape-based graphic editors

61 lines (60 loc) 2 kB
import * as React from 'react'; import { IEditorEvent } from '../editor-state/editor-events'; import { IBoundingBox } from './bounding-box'; import { IGraphicalContextData } from './graphical-context'; import { ISceneMode } from './modes'; export interface IPoint { x: number; y: number; payload?: any; } export interface IShapeDataWithoutId { type: string; customParams?: any; keyPoints: IPoint[]; graphicalContextData: IGraphicalContextData; } export interface IShapeData extends IShapeDataWithoutId { id: string; } export declare const SHAPE_BB_PADDING = 1; export interface IShapeRenderingComponentPropTypes { mode: ISceneMode; shapeData: IShapeData; onEditorEvent: (ev: IEditorEvent) => void; } export declare class ShapeRenderingComponentClassInstance extends React.Component<IShapeRenderingComponentPropTypes, any> { } export declare type ShapeRenderingComponent = typeof ShapeRenderingComponentClassInstance; export declare type ShapeDrawingGenerator = (params: { startX: number; startY: number; }) => Iterator<IPoint[]>; export interface IShapeDeclaration { type: string; displayName: string; hasSubSelectedMode?: boolean; noSelectAfterDrawn?: boolean; graphicalContextParams: string[]; initialCustomParams?: any; resizeHandles?: IShapeResizeHandle[]; ignoreGrid?: boolean; resizeProportionalOnly?: boolean; noProportionalResize?: boolean; minResizeWidth?: number; minResizeHeight?: number; RenderComponent: ShapeRenderingComponent; draw: ShapeDrawingGenerator; drawingModeCursor?: string; getBoundingBox(shape: IShapeData): IBoundingBox; } export interface IShapesDeclarations { [index: string]: IShapeDeclaration; } export declare type ICursor = 'ns-resize' | 'ew-resize' | 'nwse-resize' | 'nesw-resize'; export interface IShapeResizeHandle { relX: number; relY: number; cursor: ICursor; } export declare const DEFAULT_RESIZE_HANDLES: IShapeResizeHandle[];