-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.node.ts
37 lines (32 loc) · 1023 Bytes
/
index.node.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// first we set the env variable by importing the node env file
import { getNodeCanvas } from './src/env/node';
import type { JpegConfig, PngConfig } from 'canvas';
import {
Canvas as CanvasBase,
StaticCanvas as StaticCanvasBase,
} from './fabric';
import { FabricObject } from './src/shapes/Object/Object';
FabricObject.ownDefaults.objectCaching = false;
export * from './fabric';
export class StaticCanvas extends StaticCanvasBase {
getNodeCanvas() {
return getNodeCanvas(this.lowerCanvasEl);
}
createPNGStream(opts?: PngConfig) {
return this.getNodeCanvas().createPNGStream(opts);
}
createJPEGStream(opts?: JpegConfig) {
return this.getNodeCanvas().createJPEGStream(opts);
}
}
export class Canvas extends CanvasBase {
getNodeCanvas() {
return getNodeCanvas(this.lowerCanvasEl);
}
createPNGStream(opts?: PngConfig) {
return this.getNodeCanvas().createPNGStream(opts);
}
createJPEGStream(opts?: JpegConfig) {
return this.getNodeCanvas().createJPEGStream(opts);
}
}