UNPKG

1.66 kBTypeScriptView Raw
1export interface WatermarkOptions {
2 /** watermark text content */
3 content?: string | string[];
4 /**
5 * When the watermark is drawn, the rotation angle, in `°`. @default `-22`
6 */
7 rotate?: number;
8 /**
9 * High-definition print image source, for high-definition screen display,
10 * it is recommended to use 2x or 3x image, and priority to use image rendering watermark.
11 */
12 image?: string;
13 /** Horizontal spacing between watermarks. @default `212` */
14 gapX?: number;
15 /** vertical spacing between watermarks. @default `222` */
16 gapY?: number;
17 /** width of watermark. @default `120` */
18 width?: number;
19 /** height of watermark @default `64` */
20 height?: number;
21 /**
22 * The vertical offset of the watermark drawn on the canvas.
23 * Normally, the watermark is drawn in the middle position, ie `offsetTop = gapY / 2`
24 */
25 offsetLeft?: number;
26 /**
27 * The horizontal offset of the watermark drawn on the canvas, under normal circumstances,
28 * the watermark is drawn in the middle position, ie `offsetTop = gapX / 2`
29 */
30 offsetTop?: number;
31 /** text size @default `16` */
32 fontSize?: number;
33 /** text family @default `sans-serif` */
34 fontFamily?: string;
35 /** text weight @default `normal` */
36 fontWeight?: 'normal' | 'light' | 'weight' | number;
37 /** text color @default `rgba(0,0,0,.15)` */
38 fontColor?: string;
39 /** text style */
40 fontStyle?: CanvasFillStrokeStyles['fillStyle'];
41}
42export default class Watermark {
43 option: WatermarkOptions;
44 constructor(options: WatermarkOptions);
45 create(): Promise<string>;
46}