open-tibia-tools 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +29 -0
  2. package/effectFramesGenerator.html +42 -0
  3. package/effectFramesGenerator.ts +95 -0
  4. package/itemImageFramesGenerator.html +45 -0
  5. package/itemImageFramesGenerator.ts +140 -0
  6. package/itemImageGenerator.html +40 -0
  7. package/itemImageGenerator.ts +161 -0
  8. package/missileFramesGenerator.html +42 -0
  9. package/missileFramesGenerator.ts +95 -0
  10. package/otbEditor.html +21 -0
  11. package/otbEditor.ts +106 -0
  12. package/outfitImageGenerator.html +38 -0
  13. package/outfitImageGenerator.ts +109 -0
  14. package/outfitImagePhpGeneratorCode.ts +19 -0
  15. package/package.json +28 -0
  16. package/tests.html +29 -0
  17. package/tests.ts +218 -0
  18. package/tools/colored-outfit-images-generator/README.md +7 -0
  19. package/tools/colored-outfit-images-generator/abuse_warning.png +0 -0
  20. package/tools/colored-outfit-images-generator/animoutfit.php +103 -0
  21. package/tools/colored-outfit-images-generator/cacheGenerator.php +40 -0
  22. package/tools/colored-outfit-images-generator/config.php +25 -0
  23. package/tools/colored-outfit-images-generator/filesAsJson.php +22 -0
  24. package/tools/colored-outfit-images-generator/index.php +21 -0
  25. package/tools/colored-outfit-images-generator/libs/gifCreator.php +343 -0
  26. package/tools/colored-outfit-images-generator/libs/outfitter.php +312 -0
  27. package/tools/colored-outfit-images-generator/outfit.php +77 -0
  28. package/tools/colored-outfit-images-generator/release.php +40 -0
  29. package/tools/item-image-frames-to-animated-gif-converter/1-10/1.gif +0 -0
  30. package/tools/item-image-frames-to-animated-gif-converter/1-10/1.png +0 -0
  31. package/tools/item-image-frames-to-animated-gif-converter/1-10/10.gif +0 -0
  32. package/tools/item-image-frames-to-animated-gif-converter/1-10/10.png +0 -0
  33. package/tools/item-image-frames-to-animated-gif-converter/1-10/2.gif +0 -0
  34. package/tools/item-image-frames-to-animated-gif-converter/1-10/2.png +0 -0
  35. package/tools/item-image-frames-to-animated-gif-converter/1-10/3.gif +0 -0
  36. package/tools/item-image-frames-to-animated-gif-converter/1-10/3.png +0 -0
  37. package/tools/item-image-frames-to-animated-gif-converter/1-10/4.gif +0 -0
  38. package/tools/item-image-frames-to-animated-gif-converter/1-10/4.png +0 -0
  39. package/tools/item-image-frames-to-animated-gif-converter/1-10/5.gif +0 -0
  40. package/tools/item-image-frames-to-animated-gif-converter/1-10/5.png +0 -0
  41. package/tools/item-image-frames-to-animated-gif-converter/1-10/6.gif +0 -0
  42. package/tools/item-image-frames-to-animated-gif-converter/1-10/6.png +0 -0
  43. package/tools/item-image-frames-to-animated-gif-converter/1-10/7.gif +0 -0
  44. package/tools/item-image-frames-to-animated-gif-converter/1-10/7.png +0 -0
  45. package/tools/item-image-frames-to-animated-gif-converter/1-10/8.gif +0 -0
  46. package/tools/item-image-frames-to-animated-gif-converter/1-10/8.png +0 -0
  47. package/tools/item-image-frames-to-animated-gif-converter/1-10/9.gif +0 -0
  48. package/tools/item-image-frames-to-animated-gif-converter/1-10/9.png +0 -0
  49. package/tools/item-image-frames-to-animated-gif-converter/README.md +20 -0
  50. package/tools/item-image-frames-to-animated-gif-converter/cli_convert.php +42 -0
  51. package/tools/item-image-frames-to-animated-gif-converter/generated-zip-archives/.gitignore +3 -0
  52. package/tools/item-image-frames-to-animated-gif-converter/generated-zip-archives/index.html +1 -0
  53. package/tools/item-image-frames-to-animated-gif-converter/index.php +97 -0
  54. package/tools/item-image-frames-to-animated-gif-converter/lib/abstractPngConverterAnimation.php +87 -0
  55. package/tools/item-image-frames-to-animated-gif-converter/lib/apngCreator.php +247 -0
  56. package/tools/item-image-frames-to-animated-gif-converter/lib/converterPngToApngAnimation.php +93 -0
  57. package/tools/item-image-frames-to-animated-gif-converter/lib/converterPngToGifAnimation.php +90 -0
  58. package/tools/item-image-frames-to-animated-gif-converter/lib/gifCreator.php +339 -0
  59. package/tsconfig.json +12 -0
  60. package/webpack.config.js +53 -0
  61. package/websiteImageGeneratorBase.ts +156 -0
@@ -0,0 +1,93 @@
1
+ <?php
2
+
3
+ include_once(__DIR__ . '/abstractPngConverterAnimation.php');
4
+ include_once(__DIR__ . '/apngCreator.php');
5
+
6
+ class ConverterPngToApngAnimation extends AbstractPngConverterAnimation
7
+ {
8
+ /**
9
+ * @param string $saveToPath
10
+ * @param float $animationFrameDurationInSeconds
11
+ * @throws Exception
12
+ */
13
+ public function convert($saveToPath, $animationFrameDurationInSeconds = 0.2)
14
+ {
15
+ $gitImagesZipArchive = new ZipArchive();
16
+ if ($gitImagesZipArchive->open($saveToPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
17
+ throw new InvalidArgumentException('Failed to create ZIP archive: ' . $saveToPath);
18
+ }
19
+
20
+ foreach ($this->getInputFiles() as $fileName => $fileContents) {
21
+ $fileBaseName = basename($fileName);
22
+ if (substr($fileName, -4, 4) !== '.png') {
23
+ echo $fileName . ' is not PNG' . PHP_EOL;
24
+ continue;
25
+ }
26
+
27
+ $image = imagecreatefromstring($fileContents);
28
+ if ($image === false) {
29
+ throw new InvalidArgumentException('Cannot create image from file: ' . $fileName);
30
+ }
31
+ $width = imagesx($image);
32
+ $height = imagesy($image);
33
+
34
+ $fileNameWithoutExtension = substr($fileBaseName, 0, -4);
35
+ $fileNameData = explode('_', $fileNameWithoutExtension);
36
+ $itemId = $fileNameData[0];
37
+ $framesCount = 1;
38
+ if (isset($fileNameData[1])) {
39
+ $framesCount = intval($fileNameData[1]);
40
+ }
41
+ $frameWidth = $width / $framesCount;
42
+
43
+ $animationFrameImages = [];
44
+ $animationFrameDurations = [];
45
+
46
+ for ($frame = 0; $frame < $framesCount; ++$frame) {
47
+ $animationFrameImage = imagecreatetruecolor($frameWidth, $height);
48
+
49
+ $transparentBackgroundColor = imagecolorallocatealpha(
50
+ $animationFrameImage,
51
+ self::$transparentBackgroundColor[0],
52
+ self::$transparentBackgroundColor[1],
53
+ self::$transparentBackgroundColor[2],
54
+ self::$transparentBackgroundColor[3]
55
+ );
56
+ imagefill($animationFrameImage, 0, 0, $transparentBackgroundColor);
57
+ imagecolortransparent($animationFrameImage, $transparentBackgroundColor);
58
+ imagealphablending($animationFrameImage, true);
59
+ imagesavealpha($animationFrameImage, true);
60
+
61
+ imagecopyresampled(
62
+ $animationFrameImage,
63
+ $image,
64
+ 0,
65
+ 0,
66
+ $frame * $frameWidth,
67
+ 0,
68
+ $frameWidth,
69
+ $height,
70
+ $frameWidth,
71
+ $height
72
+ );
73
+
74
+ $animationFrameImages[] = $animationFrameImage;
75
+ $animationFrameDurations[] = $animationFrameDurationInSeconds * 1000;
76
+ }
77
+
78
+ $apngCreatore = new ApngCreator();
79
+ foreach ($animationFrameImages as $i => $animationFrameImage) {
80
+ $apngCreatore->add_image($animationFrameImage, "MIDDLE_CENTER", $animationFrameDurations[$i]);
81
+ }
82
+ $apngBinary = $apngCreatore->getAPNG();
83
+ $gitImagesZipArchive->addFromString('item_apngs/' . $itemId . '.png', $apngBinary);
84
+ $gitImagesZipArchive->setCompressionName('item_apngs/' . $itemId . '.png', ZipArchive::CM_STORE);
85
+ if ($this->printProgress) {
86
+ echo 'Generated ' . $itemId . ', frames: ' . $framesCount . PHP_EOL;
87
+ }
88
+ }
89
+ echo 'Saving PNG images to ' . $saveToPath . '... ';
90
+ $gitImagesZipArchive->close();
91
+ echo 'SAVED' . PHP_EOL;
92
+ }
93
+ }
@@ -0,0 +1,90 @@
1
+ <?php
2
+
3
+ include_once(__DIR__ . '/abstractPngConverterAnimation.php');
4
+ include_once(__DIR__ . '/gifCreator.php');
5
+
6
+ class ConverterPngToGifAnimation extends AbstractPngConverterAnimation
7
+ {
8
+ /**
9
+ * @param string $saveToPath
10
+ * @param float $animationFrameDurationInSeconds
11
+ * @throws Exception
12
+ */
13
+ public function convert($saveToPath, $animationFrameDurationInSeconds = 0.2)
14
+ {
15
+ $gitImagesZipArchive = new ZipArchive();
16
+ if ($gitImagesZipArchive->open($saveToPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
17
+ throw new InvalidArgumentException('Failed to create ZIP archive: ' . $saveToPath);
18
+ }
19
+
20
+ foreach ($this->getInputFiles() as $fileName => $fileContents) {
21
+ $fileBaseName = basename($fileName);
22
+ if (substr($fileName, -4, 4) !== '.png') {
23
+ echo $fileName . ' is not PNG' . PHP_EOL;
24
+ continue;
25
+ }
26
+
27
+ $image = imagecreatefromstring($fileContents);
28
+ if ($image === false) {
29
+ throw new InvalidArgumentException('Cannot create image from file: ' . $fileName);
30
+ }
31
+ $width = imagesx($image);
32
+ $height = imagesy($image);
33
+
34
+ $fileNameWithoutExtension = substr($fileBaseName, 0, -4);
35
+ $fileNameData = explode('_', $fileNameWithoutExtension);
36
+ $itemId = $fileNameData[0];
37
+ $framesCount = 1;
38
+ if (isset($fileNameData[1])) {
39
+ $framesCount = intval($fileNameData[1]);
40
+ }
41
+ $frameWidth = $width / $framesCount;
42
+
43
+ $animationFrameImages = [];
44
+ $animationFrameDurations = [];
45
+
46
+ for ($frame = 0; $frame < $framesCount; ++$frame) {
47
+ $animationFrameImage = imagecreatetruecolor($frameWidth, $height);
48
+
49
+ $transparentBackgroundColor = imagecolorallocate(
50
+ $animationFrameImage,
51
+ self::$transparentBackgroundColor[0],
52
+ self::$transparentBackgroundColor[1],
53
+ self::$transparentBackgroundColor[2]
54
+ );
55
+ imagefill($animationFrameImage, 0, 0, $transparentBackgroundColor);
56
+ imagecolortransparent($animationFrameImage, $transparentBackgroundColor);
57
+ imagealphablending($animationFrameImage, true);
58
+ imagesavealpha($animationFrameImage, true);
59
+
60
+ imagecopyresampled(
61
+ $animationFrameImage,
62
+ $image,
63
+ 0,
64
+ 0,
65
+ $frame * $frameWidth,
66
+ 0,
67
+ $frameWidth,
68
+ $height,
69
+ $frameWidth,
70
+ $height
71
+ );
72
+
73
+ $animationFrameImages[] = $animationFrameImage;
74
+ $animationFrameDurations[] = $animationFrameDurationInSeconds * 100;
75
+ }
76
+
77
+ $gc = new GifCreator();
78
+ $gc->create($animationFrameImages, $animationFrameDurations, 0);
79
+ $gifBinary = $gc->getGif();
80
+ $gitImagesZipArchive->addFromString('item_gifs/' . $itemId . '.gif', $gifBinary);
81
+ $gitImagesZipArchive->setCompressionName('item_gifs/' . $itemId . '.gif', ZipArchive::CM_STORE);
82
+ if ($this->printProgress) {
83
+ echo 'Generated ' . $itemId . ', frames: ' . $framesCount . PHP_EOL;
84
+ }
85
+ }
86
+ echo 'Saving GIF images to ' . $saveToPath . '... ';
87
+ $gitImagesZipArchive->close();
88
+ echo 'SAVED' . PHP_EOL;
89
+ }
90
+ }
@@ -0,0 +1,339 @@
1
+ <?php
2
+
3
+ /**
4
+ * Create an animated GIF from multiple images
5
+ *
6
+ * @update by gesior, php 8.0 compatibility
7
+ *
8
+ * @version 1.0
9
+ * @link https://github.com/Sybio/GifCreator
10
+ * @author Sybio (Clément Guillemain / @Sybio01)
11
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12
+ * @copyright Clément Guillemain
13
+ */
14
+ class GifCreator
15
+ {
16
+ /**
17
+ * @var string The gif string source (old: this->GIF)
18
+ */
19
+ private $gif;
20
+
21
+ /**
22
+ * @var string Encoder version (old: this->VER)
23
+ */
24
+ private $version;
25
+
26
+ /**
27
+ * @var boolean Check the image is build or not (old: this->IMG)
28
+ */
29
+ private $imgBuilt;
30
+
31
+ /**
32
+ * @var array Frames string sources (old: this->BUF)
33
+ */
34
+ private $frameSources;
35
+
36
+ /**
37
+ * @var integer Gif loop (old: this->LOP)
38
+ */
39
+ private $loop;
40
+
41
+ /**
42
+ * @var integer Gif dis (old: this->DIS)
43
+ */
44
+ private $dis;
45
+
46
+ /**
47
+ * @var integer Gif color (old: this->COL)
48
+ */
49
+ private $colour;
50
+
51
+ /**
52
+ * @var array (old: this->ERR)
53
+ */
54
+ private $errors;
55
+
56
+ // Methods
57
+ // ===================================================================================
58
+
59
+ /**
60
+ * Constructor
61
+ */
62
+ public function __construct()
63
+ {
64
+ $this->reset();
65
+
66
+ // Static data
67
+ $this->version = 'GifCreator: Under development';
68
+ $this->errors = array(
69
+ 'ERR00' => 'Does not supported function for only one image.',
70
+ 'ERR01' => 'Source is not a GIF image.',
71
+ 'ERR02' => 'You have to give resource image variables, image URL or image binary sources in $frames array.',
72
+ 'ERR03' => 'Does not make animation from animated GIF source.',
73
+ );
74
+ }
75
+
76
+ /**
77
+ * Create the GIF string (old: GIFEncoder)
78
+ *
79
+ * @param array $frames An array of frame: can be file paths, resource image variables, binary sources or image URLs
80
+ * @param array $durations An array containing the duration of each frame
81
+ * @param integer $loop Number of GIF loops before stopping animation (Set 0 to get an infinite loop)
82
+ *
83
+ * @return string The GIF string source
84
+ */
85
+ public function create($frames = array(), $durations = array(), $loop = 0)
86
+ {
87
+ if (!is_array($frames) && !is_array($durations)) {
88
+ throw new \Exception($this->version . ': ' . $this->errors['ERR00']);
89
+ }
90
+
91
+ $this->loop = ($loop > -1) ? $loop : 0;
92
+ $this->dis = 2;
93
+
94
+ for ($i = 0; $i < count($frames); $i++) {
95
+ if ($frames[$i] instanceof GdImage || is_resource($frames[$i])) { // Resource var
96
+
97
+ $resourceImg = $frames[$i];
98
+
99
+ ob_start();
100
+ imagegif($frames[$i]);
101
+ $this->frameSources[] = ob_get_contents();
102
+ ob_end_clean();
103
+ } elseif (is_string($frames[$i])) { // File path or URL or Binary source code
104
+
105
+ if (file_exists($frames[$i]) || filter_var($frames[$i], FILTER_VALIDATE_URL)) { // File path
106
+
107
+ $frames[$i] = file_get_contents($frames[$i]);
108
+ }
109
+
110
+ $resourceImg = imagecreatefromstring($frames[$i]);
111
+
112
+ ob_start();
113
+ imagegif($resourceImg);
114
+ $this->frameSources[] = ob_get_contents();
115
+ ob_end_clean();
116
+ } else { // Fail
117
+
118
+ throw new \Exception($this->version . ': ' . $this->errors['ERR02']);
119
+ }
120
+
121
+ if ($i == 0) {
122
+ $colour = imagecolortransparent($resourceImg);
123
+ }
124
+
125
+ if (substr($this->frameSources[$i], 0, 6) != 'GIF87a' && substr(
126
+ $this->frameSources[$i],
127
+ 0,
128
+ 6
129
+ ) != 'GIF89a') {
130
+ throw new \Exception($this->version . ': ' . $i . ' ' . $this->errors['ERR01']);
131
+ }
132
+
133
+ for ($j = (13 + 3 * (2 << (ord($this->frameSources[$i] [10]) & 0x07))), $k = true; $k; $j++) {
134
+ switch ($this->frameSources[$i] [$j]) {
135
+ case '!':
136
+
137
+ if ((substr($this->frameSources[$i], ($j + 3), 8)) == 'NETSCAPE') {
138
+ throw new \Exception(
139
+ $this->version . ': ' . $this->errors['ERR03'] . ' (' . ($i + 1) . ' source).'
140
+ );
141
+ }
142
+
143
+ break;
144
+
145
+ case ';':
146
+
147
+ $k = false;
148
+ break;
149
+ }
150
+ }
151
+
152
+ unset($resourceImg);
153
+ }
154
+
155
+ if (isset($colour)) {
156
+ $this->colour = $colour;
157
+ } else {
158
+ $red = $green = $blue = 0;
159
+ $this->colour = ($red > -1 && $green > -1 && $blue > -1) ? ($red | ($green << 8) | ($blue << 16)) : -1;
160
+ }
161
+
162
+ $this->gifAddHeader();
163
+
164
+ for ($i = 0; $i < count($this->frameSources); $i++) {
165
+ $this->addGifFrames($i, $durations[$i]);
166
+ }
167
+
168
+ $this->gifAddFooter();
169
+
170
+ return $this->gif;
171
+ }
172
+
173
+ // Internals
174
+ // ===================================================================================
175
+
176
+ /**
177
+ * Add the header gif string in its source (old: GIFAddHeader)
178
+ */
179
+ public function gifAddHeader()
180
+ {
181
+ $cmap = 0;
182
+
183
+ if (ord($this->frameSources[0] [10]) & 0x80) {
184
+ $cmap = 3 * (2 << (ord($this->frameSources[0] [10]) & 0x07));
185
+
186
+ $this->gif .= substr($this->frameSources[0], 6, 7);
187
+ $this->gif .= substr($this->frameSources[0], 13, $cmap);
188
+ $this->gif .= "!\377\13NETSCAPE2.0\3\1" . $this->encodeAsciiToChar($this->loop) . "\0";
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Add the frame sources to the GIF string (old: GIFAddFrames)
194
+ *
195
+ * @param integer $i
196
+ * @param integer $d
197
+ */
198
+ public function addGifFrames($i, $d)
199
+ {
200
+ $Locals_str = 13 + 3 * (2 << (ord($this->frameSources[$i] [10]) & 0x07));
201
+
202
+ $Locals_end = strlen($this->frameSources[$i]) - $Locals_str - 1;
203
+ $Locals_tmp = substr($this->frameSources[$i], $Locals_str, $Locals_end);
204
+
205
+ $Global_len = 2 << (ord($this->frameSources[0] [10]) & 0x07);
206
+ $Locals_len = 2 << (ord($this->frameSources[$i] [10]) & 0x07);
207
+
208
+ $Global_rgb = substr($this->frameSources[0], 13, 3 * (2 << (ord($this->frameSources[0] [10]) & 0x07)));
209
+ $Locals_rgb = substr($this->frameSources[$i], 13, 3 * (2 << (ord($this->frameSources[$i] [10]) & 0x07)));
210
+
211
+ $Locals_ext = "!\xF9\x04" . chr(($this->dis << 2) + 0) . chr(($d >> 0) & 0xFF) . chr(
212
+ ($d >> 8) & 0xFF
213
+ ) . "\x0\x0";
214
+
215
+ if ($this->colour > -1 && ord($this->frameSources[$i] [10]) & 0x80) {
216
+ for ($j = 0; $j < (2 << (ord($this->frameSources[$i] [10]) & 0x07)); $j++) {
217
+ if (ord($Locals_rgb [3 * $j + 0]) == (($this->colour >> 16) & 0xFF) &&
218
+ ord($Locals_rgb [3 * $j + 1]) == (($this->colour >> 8) & 0xFF) &&
219
+ ord($Locals_rgb [3 * $j + 2]) == (($this->colour >> 0) & 0xFF)
220
+ ) {
221
+ $Locals_ext = "!\xF9\x04" . chr(($this->dis << 2) + 1) . chr(($d >> 0) & 0xFF) . chr(
222
+ ($d >> 8) & 0xFF
223
+ ) . chr($j) . "\x0";
224
+ break;
225
+ }
226
+ }
227
+ }
228
+
229
+ switch ($Locals_tmp [0]) {
230
+ case '!':
231
+
232
+ $Locals_img = substr($Locals_tmp, 8, 10);
233
+ $Locals_tmp = substr($Locals_tmp, 18, strlen($Locals_tmp) - 18);
234
+
235
+ break;
236
+
237
+ case ',':
238
+
239
+ $Locals_img = substr($Locals_tmp, 0, 10);
240
+ $Locals_tmp = substr($Locals_tmp, 10, strlen($Locals_tmp) - 10);
241
+
242
+ break;
243
+ }
244
+
245
+ if (ord($this->frameSources[$i] [10]) & 0x80 && $this->imgBuilt) {
246
+ if ($Global_len == $Locals_len) {
247
+ if ($this->gifBlockCompare($Global_rgb, $Locals_rgb, $Global_len)) {
248
+ $this->gif .= $Locals_ext . $Locals_img . $Locals_tmp;
249
+ } else {
250
+ $byte = ord($Locals_img [9]);
251
+ $byte |= 0x80;
252
+ $byte &= 0xF8;
253
+ $byte |= (ord($this->frameSources[0] [10]) & 0x07);
254
+ $Locals_img [9] = chr($byte);
255
+ $this->gif .= $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp;
256
+ }
257
+ } else {
258
+ $byte = ord($Locals_img [9]);
259
+ $byte |= 0x80;
260
+ $byte &= 0xF8;
261
+ $byte |= (ord($this->frameSources[$i] [10]) & 0x07);
262
+ $Locals_img [9] = chr($byte);
263
+ $this->gif .= $Locals_ext . $Locals_img . $Locals_rgb . $Locals_tmp;
264
+ }
265
+ } else {
266
+ $this->gif .= $Locals_ext . $Locals_img . $Locals_tmp;
267
+ }
268
+
269
+ $this->imgBuilt = true;
270
+ }
271
+
272
+ /**
273
+ * Add the gif string footer char (old: GIFAddFooter)
274
+ */
275
+ public function gifAddFooter()
276
+ {
277
+ $this->gif .= ';';
278
+ }
279
+
280
+ /**
281
+ * Compare two block and return the version (old: GIFBlockCompare)
282
+ *
283
+ * @param string $globalBlock
284
+ * @param string $localBlock
285
+ * @param integer $length
286
+ *
287
+ * @return integer
288
+ */
289
+ public function gifBlockCompare($globalBlock, $localBlock, $length)
290
+ {
291
+ for ($i = 0; $i < $length; $i++) {
292
+ if ($globalBlock [3 * $i + 0] != $localBlock [3 * $i + 0] ||
293
+ $globalBlock [3 * $i + 1] != $localBlock [3 * $i + 1] ||
294
+ $globalBlock [3 * $i + 2] != $localBlock [3 * $i + 2]) {
295
+ return 0;
296
+ }
297
+ }
298
+
299
+ return 1;
300
+ }
301
+
302
+ /**
303
+ * Encode an ASCII char into a string char (old: GIFWord)
304
+ *
305
+ * $param integer $char ASCII char
306
+ *
307
+ * @return string
308
+ */
309
+ public function encodeAsciiToChar($char)
310
+ {
311
+ return (chr($char & 0xFF) . chr(($char >> 8) & 0xFF));
312
+ }
313
+
314
+ /**
315
+ * Reset and clean the current object
316
+ */
317
+ public function reset()
318
+ {
319
+ $this->frameSources;
320
+ $this->gif = 'GIF89a'; // the GIF header
321
+ $this->imgBuilt = false;
322
+ $this->loop = 0;
323
+ $this->dis = 2;
324
+ $this->colour = -1;
325
+ }
326
+
327
+ // Getter / Setter
328
+ // ===================================================================================
329
+
330
+ /**
331
+ * Get the final GIF image string (old: GetAnimation)
332
+ *
333
+ * @return string
334
+ */
335
+ public function getGif()
336
+ {
337
+ return $this->gif;
338
+ }
339
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "es6",
4
+ "target": "es6",
5
+ "sourceMap": true,
6
+ "allowSyntheticDefaultImports": true,
7
+ "esModuleInterop": true,
8
+ "moduleResolution": "node",
9
+ "skipLibCheck": true,
10
+ "types": []
11
+ }
12
+ }
@@ -0,0 +1,53 @@
1
+ const path = require('path');
2
+ const CopyPlugin = require('copy-webpack-plugin');
3
+
4
+ module.exports = {
5
+ mode: 'production',
6
+ entry: {
7
+ tests: './tests.ts',
8
+ effectFramesGenerator: './effectFramesGenerator.ts',
9
+ missileFramesGenerator: './missileFramesGenerator.ts',
10
+ itemImageGenerator: './itemImageGenerator.ts',
11
+ itemImageFramesGenerator: './itemImageFramesGenerator.ts',
12
+ outfitImageGenerator: './outfitImageGenerator.ts',
13
+ otbEditor: './otbEditor.ts'
14
+ },
15
+ output: {
16
+ filename: '[name].js',
17
+ path: path.resolve(__dirname, 'js')
18
+ },
19
+ module: {
20
+ rules: [{
21
+ test: /\.tsx?$/,
22
+ exclude: /node_modules/,
23
+ use: {
24
+ loader: 'ts-loader',
25
+ options: {
26
+ transpileOnly: true
27
+ }
28
+ }
29
+ }]
30
+ },
31
+ resolve: {
32
+ extensions: ['.tsx', '.ts', '.js']
33
+ },
34
+ optimization: {
35
+ splitChunks: {
36
+ cacheGroups: {
37
+ vendor: {
38
+ test: /[\\/]node_modules[\\/]/,
39
+ name: 'vendor',
40
+ chunks: 'all',
41
+ enforce: true
42
+ }
43
+ }
44
+ }
45
+ },
46
+ plugins: [
47
+ new CopyPlugin({
48
+ patterns: [
49
+ { from: './node_modules/gif.js/dist/gif.worker.js', to: 'gif.worker.js' }
50
+ ]
51
+ })
52
+ ]
53
+ };