painter-kernel
Version:
painter 核心逻辑库
115 lines (114 loc) • 3.29 kB
TypeScript
import { CSSProperties } from 'react';
export declare const penCache: {
viewRect: {
[id: string]: {
width: number;
height: number;
left: number;
top: number;
right: number;
bottom: number;
} | null;
};
textLines: {
[id: string]: Array<{
text: string;
x: number;
y: number;
measuredWith: number;
textDecoration?: {
moveTo: number[];
lineTo: number[];
};
}> | null;
};
};
export declare const clearPenCache: (id?: string) => void;
export interface IView {
type: 'rect' | 'text' | 'image' | 'qrcode' | 'inlineText';
text?: string;
url?: string;
id?: string;
textList: Array<{
text: string;
css: CSSProperties & Partial<{
align: string;
verticalAlign: string;
mode: 'aspectFill' | 'scaleToFill' | 'auto';
textStyle: 'normal' | 'stroke';
scalable: boolean;
deletable: boolean;
}>;
}>;
content?: string;
css: CSSProperties & Partial<{
align: string;
verticalAlign: string;
mode: 'aspectFill' | 'scaleToFill' | 'auto';
textStyle: 'normal' | 'stroke';
scalable: boolean;
deletable: boolean;
}>;
}
export interface IPalette {
background: string;
width: string;
height: string;
borderRadius: string;
views: Array<IView>;
}
declare type InnerView = IView & Partial<{
sWidth: number;
sHeight: number;
rect: Partial<{
left: number;
top: number;
right: number;
bottom: number;
x: number;
y: number;
minWidth: number;
startX: number;
startY: number;
endX: number;
endY: number;
}>;
}>;
export declare class Pen {
private ctx;
private data;
style: {
width: number;
height: number;
};
constructor(ctx: CanvasRenderingContext2D, data: IPalette);
paint(callback?: () => void): Promise<void>;
_background(): Promise<void>;
_drawAbsolute(view: InnerView): Promise<void>;
_border({ borderRadius, width, height, borderWidth, borderStyle, }: {
borderRadius?: string | number;
width: number;
height: number;
borderWidth?: string | number;
borderStyle?: string;
}): void;
_doClip(borderRadius: string | number, width: number, height: number, borderStyle?: string): void;
_doBorder(view: IView, width: number, height: number): void;
_preProcess(view: InnerView, notClip?: Boolean): {
width: number;
height: any;
x: any;
y: any;
extra: any;
};
_doPaddings(view: IView): number[];
_doBackground(view: IView): void;
_drawQRCode(view: IView): void;
_drawAbsImage(view: InnerView): Promise<void>;
_fillAbsText(view: InnerView): void;
_fillAbsInlineText(view: any): void;
_drawAbsRect(view: InnerView): void;
_doShadow(view: InnerView): void;
_getAngle(angle: string): number;
}
export {};