오윤석

using gif.js (dhdbstjr98 customized)

...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
9 "license": "ISC", 9 "license": "ISC",
10 "dependencies": { 10 "dependencies": {
11 "@babel/plugin-proposal-class-properties": "^7.13.0", 11 "@babel/plugin-proposal-class-properties": "^7.13.0",
12 + "@dhdbstjr98/gif.js": "^1.0.0",
12 "gifencoder": "^2.0.1", 13 "gifencoder": "^2.0.1",
13 "hangul-js": "^0.2.6", 14 "hangul-js": "^0.2.6",
14 "stream": "0.0.2" 15 "stream": "0.0.2"
...@@ -1168,6 +1169,15 @@ ...@@ -1168,6 +1169,15 @@
1168 "to-fast-properties": "^2.0.0" 1169 "to-fast-properties": "^2.0.0"
1169 } 1170 }
1170 }, 1171 },
1172 + "node_modules/@dhdbstjr98/gif.js": {
1173 + "version": "1.0.0",
1174 + "resolved": "https://registry.npmjs.org/@dhdbstjr98/gif.js/-/gif.js-1.0.0.tgz",
1175 + "integrity": "sha512-LI7RyCiTnEmuPBOPnIpZosT3zSuSGXwjdkjQC+HwiYKjBZeIozoKWhIwgE0w533rDUyRxM3dhmAMzlyIzKx/OQ==",
1176 + "dependencies": {
1177 + "buffer": "^6.0.3",
1178 + "events": "^3.3.0"
1179 + }
1180 + },
1171 "node_modules/@discoveryjs/json-ext": { 1181 "node_modules/@discoveryjs/json-ext": {
1172 "version": "0.5.2", 1182 "version": "0.5.2",
1173 "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz", 1183 "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz",
...@@ -1854,6 +1864,25 @@ ...@@ -1854,6 +1864,25 @@
1854 "node": ">=0.10.0" 1864 "node": ">=0.10.0"
1855 } 1865 }
1856 }, 1866 },
1867 + "node_modules/base64-js": {
1868 + "version": "1.5.1",
1869 + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
1870 + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
1871 + "funding": [
1872 + {
1873 + "type": "github",
1874 + "url": "https://github.com/sponsors/feross"
1875 + },
1876 + {
1877 + "type": "patreon",
1878 + "url": "https://www.patreon.com/feross"
1879 + },
1880 + {
1881 + "type": "consulting",
1882 + "url": "https://feross.org/support"
1883 + }
1884 + ]
1885 + },
1857 "node_modules/bcrypt-pbkdf": { 1886 "node_modules/bcrypt-pbkdf": {
1858 "version": "1.0.2", 1887 "version": "1.0.2",
1859 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 1888 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
...@@ -1953,6 +1982,29 @@ ...@@ -1953,6 +1982,29 @@
1953 "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" 1982 "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
1954 } 1983 }
1955 }, 1984 },
1985 + "node_modules/buffer": {
1986 + "version": "6.0.3",
1987 + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
1988 + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
1989 + "funding": [
1990 + {
1991 + "type": "github",
1992 + "url": "https://github.com/sponsors/feross"
1993 + },
1994 + {
1995 + "type": "patreon",
1996 + "url": "https://www.patreon.com/feross"
1997 + },
1998 + {
1999 + "type": "consulting",
2000 + "url": "https://feross.org/support"
2001 + }
2002 + ],
2003 + "dependencies": {
2004 + "base64-js": "^1.3.1",
2005 + "ieee754": "^1.2.1"
2006 + }
2007 + },
1956 "node_modules/buffer-from": { 2008 "node_modules/buffer-from": {
1957 "version": "1.1.1", 2009 "version": "1.1.1",
1958 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", 2010 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
...@@ -2762,7 +2814,6 @@ ...@@ -2762,7 +2814,6 @@
2762 "version": "3.3.0", 2814 "version": "3.3.0",
2763 "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", 2815 "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
2764 "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", 2816 "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
2765 - "dev": true,
2766 "engines": { 2817 "engines": {
2767 "node": ">=0.8.x" 2818 "node": ">=0.8.x"
2768 } 2819 }
...@@ -3466,6 +3517,25 @@ ...@@ -3466,6 +3517,25 @@
3466 "node": ">=0.10.0" 3517 "node": ">=0.10.0"
3467 } 3518 }
3468 }, 3519 },
3520 + "node_modules/ieee754": {
3521 + "version": "1.2.1",
3522 + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
3523 + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
3524 + "funding": [
3525 + {
3526 + "type": "github",
3527 + "url": "https://github.com/sponsors/feross"
3528 + },
3529 + {
3530 + "type": "patreon",
3531 + "url": "https://www.patreon.com/feross"
3532 + },
3533 + {
3534 + "type": "consulting",
3535 + "url": "https://feross.org/support"
3536 + }
3537 + ]
3538 + },
3469 "node_modules/ignore-walk": { 3539 "node_modules/ignore-walk": {
3470 "version": "3.0.3", 3540 "version": "3.0.3",
3471 "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz", 3541 "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz",
...@@ -7314,6 +7384,15 @@ ...@@ -7314,6 +7384,15 @@
7314 "to-fast-properties": "^2.0.0" 7384 "to-fast-properties": "^2.0.0"
7315 } 7385 }
7316 }, 7386 },
7387 + "@dhdbstjr98/gif.js": {
7388 + "version": "1.0.0",
7389 + "resolved": "https://registry.npmjs.org/@dhdbstjr98/gif.js/-/gif.js-1.0.0.tgz",
7390 + "integrity": "sha512-LI7RyCiTnEmuPBOPnIpZosT3zSuSGXwjdkjQC+HwiYKjBZeIozoKWhIwgE0w533rDUyRxM3dhmAMzlyIzKx/OQ==",
7391 + "requires": {
7392 + "buffer": "^6.0.3",
7393 + "events": "^3.3.0"
7394 + }
7395 + },
7317 "@discoveryjs/json-ext": { 7396 "@discoveryjs/json-ext": {
7318 "version": "0.5.2", 7397 "version": "0.5.2",
7319 "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz", 7398 "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz",
...@@ -7923,6 +8002,11 @@ ...@@ -7923,6 +8002,11 @@
7923 } 8002 }
7924 } 8003 }
7925 }, 8004 },
8005 + "base64-js": {
8006 + "version": "1.5.1",
8007 + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
8008 + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
8009 + },
7926 "bcrypt-pbkdf": { 8010 "bcrypt-pbkdf": {
7927 "version": "1.0.2", 8011 "version": "1.0.2",
7928 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 8012 "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
...@@ -8006,6 +8090,15 @@ ...@@ -8006,6 +8090,15 @@
8006 "node-releases": "^1.1.70" 8090 "node-releases": "^1.1.70"
8007 } 8091 }
8008 }, 8092 },
8093 + "buffer": {
8094 + "version": "6.0.3",
8095 + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
8096 + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
8097 + "requires": {
8098 + "base64-js": "^1.3.1",
8099 + "ieee754": "^1.2.1"
8100 + }
8101 + },
8009 "buffer-from": { 8102 "buffer-from": {
8010 "version": "1.1.1", 8103 "version": "1.1.1",
8011 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", 8104 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
...@@ -8664,8 +8757,7 @@ ...@@ -8664,8 +8757,7 @@
8664 "events": { 8757 "events": {
8665 "version": "3.3.0", 8758 "version": "3.3.0",
8666 "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", 8759 "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
8667 - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", 8760 + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="
8668 - "dev": true
8669 }, 8761 },
8670 "execa": { 8762 "execa": {
8671 "version": "5.0.0", 8763 "version": "5.0.0",
...@@ -9248,6 +9340,11 @@ ...@@ -9248,6 +9340,11 @@
9248 "safer-buffer": ">= 2.1.2 < 3" 9340 "safer-buffer": ">= 2.1.2 < 3"
9249 } 9341 }
9250 }, 9342 },
9343 + "ieee754": {
9344 + "version": "1.2.1",
9345 + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
9346 + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
9347 + },
9251 "ignore-walk": { 9348 "ignore-walk": {
9252 "version": "3.0.3", 9349 "version": "3.0.3",
9253 "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz", 9350 "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz",
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
20 }, 20 },
21 "dependencies": { 21 "dependencies": {
22 "@babel/plugin-proposal-class-properties": "^7.13.0", 22 "@babel/plugin-proposal-class-properties": "^7.13.0",
23 + "@dhdbstjr98/gif.js": "^1.0.0",
23 "gifencoder": "^2.0.1", 24 "gifencoder": "^2.0.1",
24 "hangul-js": "^0.2.6", 25 "hangul-js": "^0.2.6",
25 "stream": "0.0.2" 26 "stream": "0.0.2"
......
1 -import GIF from "gifencoder"; 1 +import GIF from "@dhdbstjr98/gif.js";
2 import { fabric } from "fabric"; 2 import { fabric } from "fabric";
3 import Component from "./components"; 3 import Component from "./components";
4 4
...@@ -12,23 +12,24 @@ export class GifGenerator { ...@@ -12,23 +12,24 @@ export class GifGenerator {
12 } 12 }
13 13
14 _initializeGif() { 14 _initializeGif() {
15 - this.gif = new GIF(this.width, this.height); 15 + this.gif = new GIF({
16 - this.gif.setTransparent(null); 16 + width: this.width,
17 - this.gif.setRepeat(0); 17 + height: this.height,
18 - this.gif.setQuality(10); 18 + transparent: null,
19 - this.gif.start(); 19 + repeat: 0,
20 + setQuality: 10,
21 + });
20 } 22 }
21 23
22 _addFrame(delay = 0) { 24 _addFrame(delay = 0) {
23 - this.gif.setDelay(delay); 25 + this.gif.addFrame(this.canvas.getContext(), { delay, copy: true });
24 - this.gif.addFrame(this.canvas.getContext());
25 } 26 }
26 27
27 - _render() { 28 + _render(callback) {
28 - this.gif.finish(); 29 + this.gif.on("finished", (blob) => {
29 - const byte = new Uint8Array(this.gif.out.data); 30 + callback(blob);
30 - 31 + });
31 - return new Blob([byte], { type: "image/gif" }); 32 + this.gif.render();
32 } 33 }
33 34
34 make() { 35 make() {
...@@ -67,7 +68,7 @@ export class GifGenerator { ...@@ -67,7 +68,7 @@ export class GifGenerator {
67 draw(); 68 draw();
68 } else { 69 } else {
69 this.canvas.off("after:render", draw); 70 this.canvas.off("after:render", draw);
70 - resolve(this._render()); 71 + this._render(resolve);
71 } 72 }
72 } else { 73 } else {
73 this.canvas.remove( 74 this.canvas.remove(
......
This diff could not be displayed because it is too large.