@gorpacrate/core-graphics
Version:
A core library for creating shape-based graphic editors
50 lines (49 loc) • 1.55 kB
TypeScript
import { IContextMenuState, ICursor, IGraphicalContextData, IPoint, IScene, ISceneMode, IShapesDeclarations } from '../declarations';
import { IHistoryEvent, IPersistedHistoryEvent } from '../history/history-event';
import { EditorAction } from './editor-action';
export interface IEditorMouseState {
down: boolean;
inside: boolean;
x: number;
y: number;
lastDownX: number;
lastDownY: number;
cursor?: ICursor;
ignoreCursorUp: boolean;
}
export interface IEditorGridState {
on: boolean;
size: number;
}
export interface IEditorViewportState {
x: number;
y: number;
}
export interface IEditorModifierKeys {
[index: string]: boolean;
}
export interface IEditorState {
mode: ISceneMode;
viewport: IEditorViewportState;
grid: IEditorGridState;
contextMenu: IContextMenuState;
mouse: IEditorMouseState;
modifierKeys: IEditorModifierKeys;
shapesDeclarations: IShapesDeclarations;
author: string;
graphicalContextData: IGraphicalContextData;
persistedHistory: IPersistedHistoryEvent[];
persistedScene: IScene;
scene: IScene;
previewedHistoryEvents: IHistoryEvent[];
editorActionsQueue: EditorAction[];
}
export declare const initialGridState: IEditorGridState;
export declare function getInitialEditorState(params: {
shapesDeclarations: IShapesDeclarations;
author: string;
viewport?: IPoint;
graphicalContextData?: IGraphicalContextData;
persistedHistory?: IPersistedHistoryEvent[];
grid?: IEditorGridState;
}): IEditorState;