@meta2d/core
Version:
@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .
60 lines (59 loc) • 1.96 kB
TypeScript
import { Pen } from '../pen';
import { Point } from "../point";
export interface GridDrawerContext {
store: any;
canvas: HTMLCanvasElement;
/** 实际要绘制的矩形区域(已考虑 scope 和 clip) */
area: {
x: number;
y: number;
width: number;
height: number;
};
/** 网格对齐原点 */
align: {
x: number;
y: number;
};
size: number;
color: string;
rotate?: number;
scale: number;
mousePos?: Point;
}
export type GridDrawer = (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, context: GridDrawerContext, mousePos: Point) => boolean | undefined;
export declare const globalStore: {
version: string;
path2dDraws: {
[key: string]: (pen: Pen, ctx?: CanvasRenderingContext2D) => Path2D;
};
canvasDraws: {
[key: string]: (ctx: CanvasRenderingContext2D, pen: Pen) => void;
};
lineAnimateDraws: {
[key: string]: (ctx: CanvasRenderingContext2D, pen: Pen, state: any, index: number) => void;
};
anchors: {
[key: string]: (pen: Pen) => void;
};
htmlElements: {
[key: string]: HTMLImageElement;
};
gridDrawers: {
[key: string]: GridDrawer;
};
};
export declare function register(path2dFns: {
[key: string]: (pen: Pen, ctx?: CanvasRenderingContext2D) => Path2D;
}): void;
export declare function registerCanvasDraw(drawFns: {
[key: string]: (ctx: CanvasRenderingContext2D, pen: Pen) => void;
}): void;
export declare function registerAnchors(anchorsFns: {
[key: string]: (pen: Pen) => void;
}): void;
export declare function registerLineAnimateDraws(lineAnimateDraws: {
[key: string]: (ctx: CanvasRenderingContext2D, line: Pen, pos: any, index: number) => void;
}): void;
export declare function registerGridDrawer(name: string, drawer: GridDrawer): void;
export declare function unregisterGridDrawer(name: string): void;