-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
index.node.ts
43 lines (38 loc) · 1.15 KB
/
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
38
39
40
41
42
43
// 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.getElement());
}
createPNGStream(opts?: PngConfig) {
return this.getNodeCanvas().createPNGStream(opts);
}
createJPEGStream(opts?: JpegConfig) {
return this.getNodeCanvas().createJPEGStream(opts);
}
}
/**
* **NOTICE**:
* {@link Canvas} is designed for interactivity.
* Therefore, using it in node has no benefit.
* Use {@link StaticCanvas} instead.
*/
export class Canvas extends CanvasBase {
getNodeCanvas() {
return getNodeCanvas(this.getElement());
}
createPNGStream(opts?: PngConfig) {
return this.getNodeCanvas().createPNGStream(opts);
}
createJPEGStream(opts?: JpegConfig) {
return this.getNodeCanvas().createJPEGStream(opts);
}
}