mp-cover-layer
Version:
a plugin to make an image with canvas, it can use in weapp
168 lines • 4.71 kB
TypeScript
/// <reference types="src/wx" />
/// <reference types="src/my" />
export default class CoverLayer {
canvas: any;
ctx: any;
clientType: string;
constructor(options?: any);
/**
* 初始化canvas对象
*
* @param {*} options
* @memberof CoverLayer
*/
init(canvasId: string): Promise<{}>;
private initWeapp;
private initAlipay;
/**
* 放一个矩形
*
* @param {*} { background = '#fff', width = 0, height = 0, x = 0, y = 0, rotate = 0 }
* @returns
* @memberof Maker
*/
putFillRect({ background, width, height, x, y, rotate }: {
background?: string;
width?: number;
height?: number;
x?: number;
y?: number;
rotate?: number;
}): Promise<void>;
/**
* 放一条线
*
* @param {*} { width = 1, lineWidth = width, color = '#000', start = { x: 0, y: 0 }, end = null }
* @returns
* @memberof Maker
*/
putLine({ width, lineWidth, color, start, end }: {
width?: number;
lineWidth?: any;
color?: string;
start?: {
x: number;
y: number;
};
end?: any;
}): Promise<never>;
/**
* 放一个多边形
*
* @param {*} { background = '', borderWidth = 0, borderColor = '', paths = [] }
* @returns
* @memberof Maker
*/
putPolygon({ background, borderWidth, borderColor, paths }: {
background?: string;
borderWidth?: number;
borderColor?: string;
paths?: any[];
}): Promise<void>;
/**
* 放置图层,可批量放置img/qrcode/text/paragraph/rect/line/polygon等
*
* @param {*} [layers=[]]
* @param {Function} callback
* @memberof CoverLayer
*/
putLayers(layers: any[], callback: Function): Promise<void>;
/**
* 放文字
*
* @param {*} { text = '', x = 0, y = 0, fontSize = 12, rotate = 0, textBaseline = 'middle', color = '#000', fontColor = color, align = 'left', fontWeight = 'normal', fontFamily = 'sans-serif' }
* @returns
* @memberof Maker
*/
putText({ text, x, y, fontSize, rotate, textBaseline, color, fontColor, align, fontWeight, fontFamily }: {
text?: string;
x?: number;
y?: number;
fontSize?: number;
rotate?: number;
textBaseline?: string;
color?: string;
fontColor?: any;
align?: string;
fontWeight?: string;
fontFamily?: string;
}): Promise<any>;
/**
* 放文段, 可换行
*
* @param {*} { text = '', x = 0, y = 0, fontSize = 12, textBaseline = 'middle', color = '#000', width = 0, fontColor = color, align = 'left', fontWeight = 'normal', fontFamily = 'sans-serif' }
* @memberof Maker
*/
putParagraph({ text, x, y, fontSize, textBaseline, lineHeight, color, width, fontColor, align, fontWeight, fontFamily }: {
text?: string;
x?: number;
y?: number;
fontSize?: number;
textBaseline?: string;
lineHeight?: number;
color?: string;
width?: number;
fontColor?: any;
align?: string;
fontWeight?: string;
fontFamily?: string;
}): Promise<any>;
/**
* 放圆形图片
*
* @param {*} { img = '', x = 0, y = 0, width = 0, height = 0, rotate = 0 }
* @returns
* @memberof Maker
*/
putCircularImg({ img, x, y, width, height, rotate }: {
img?: string;
x?: number;
y?: number;
width?: number;
height?: number;
rotate?: number;
}): Promise<void>;
/**
*将路径的图片读取为dom
*
* @param {*} url
* @returns
* @memberof Maker
*/
loadImg(url: any): Promise<any>;
/**
* 获取最终图片
*
* @returns base64
* @memberof Maker
*/
canvasToDataUrl(type?: string, value?: number): Promise<any>;
toDataURL(type?: string, value?: number): Promise<any>;
/**
* 输出临时存放路径
*
* @param {string} [fileType='png']
* @param {number} [quality=1.0]
* @returns {Promise<any>}
* @memberof CoverLayer
*/
toTempFilePath(fileType?: string, quality?: number): Promise<any>;
/**
* 放图片
*
* @param {*} { img = '', x = 0, y = 0, width = 0, height = 0, rotate = 0 }
* @returns
* @memberof Maker
*/
putImg({ img, x, y, width, height, rotate }: {
img?: string;
x?: number;
y?: number;
width?: number;
height?: number;
rotate?: number;
}): Promise<any>;
getCanvas(): any;
getContext(): any;
}
//# sourceMappingURL=index.d.ts.map