MCPcopy Index your code
hub / github.com/Moddable-OpenSource/moddable / run

Method run

tools/image2cs.js:365–479  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

363 return result.buffer;
364 }
365 run() {
366 var fps_numerator;
367 var fps_denominator;
368 var frames = new Array;
369 if (this.directory) {
370 var names = this.enumerateDirectory(this.inputPath);
371 names.sort();
372 var c = names.length;
373 for (var i = 0; i < c; i++) {
374 var path = this.inputPath + this.slash + names[i];
375 var parts = this.splitPath(path);
376 if (parts.extension == ".png") {
377 this.readPNG(path, frames);
378 }
379 else if ((parts.extension == ".jpg") || (parts.extension == ".jpeg")) {
380 this.readJPEG(path, frames);
381 }
382 }
383 var parts = this.splitPath(this.inputPath);
384 var a = parts.extension.match(/\.([0-9]+)fps/);
385 fps_numerator = 1;
386 fps_denominator = (a && (a.length == 2) && (a[1] !== undefined)) ? parseInt(a[1]) : 30;
387 }
388 else {
389 var parts = this.splitPath(this.inputPath);
390 if (parts.extension == ".gif") {
391 var array = this.readGIF(this.readFileBuffer(this.inputPath));
392 var gifWidth = array.width;
393 var gifHeight = array.height;
394 var gifDuration = array.reduce((sum, item) => sum + item.delay, 0);
395 var width, height;
396 switch (this.rotation) {
397 case 0:
398 case 180:
399 width = gifWidth;
400 height = gifHeight;
401 break;
402 case 90:
403 case 270:
404 width = gifHeight;
405 height = gifWidth;
406 break;
407 }
408 var c = array.length;
409 for (var i = 0; i < c; i++) {
410 var pixels;
411 switch (this.rotation) {
412 case 0:
413 pixels = array[i];
414 break;
415 case 90:
416 pixels = this.rotate90(array[i], gifWidth, gifHeight);
417 break;
418 case 180:
419 pixels = this.rotate180(array[i], gifWidth, gifHeight);
420 break;
421 case 270:
422 pixels = this.rotate270(array[i], gifWidth, gifHeight);

Callers

nothing calls this directly

Calls 10

readPNGMethod · 0.80
readJPEGMethod · 0.80
closeMethod · 0.65
rotate90Method · 0.45
rotate180Method · 0.45
rotate270Method · 0.45
pushMethod · 0.45
compressMethod · 0.45
writeByteMethod · 0.45
writeBufferMethod · 0.45

Tested by

no test coverage detected