Guest User

Untitled

a guest
May 7th, 2020
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. /**
  2. * @author munrocket / https://twitter.com/munrocket_twit
  3. */
  4.  
  5. const printImage = require( 'image-output' );
  6. const jimp = require( 'jimp' );
  7. const fs = require( 'fs' );
  8.  
  9. const oututRes = 4096;
  10.  
  11. ( async () => {
  12.  
  13. const pinkPixel = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8rvTjPwAHOwMSKpP6zwAAAABJRU5ErkJggg==';
  14. let output = ( await jimp.read( Buffer.from( pinkPixel, 'base64' ) ) ).resize( oututRes, oututRes );
  15.  
  16. let examples = [];
  17. eval( fs.readFileSync( './examples/files.js' ).toString() );
  18. Object.keys( files ).forEach( key => {
  19. files[ key ].forEach( name => examples.push( name ) );
  20. });
  21.  
  22. const sideSize = Math.ceil( Math.sqrt( examples.length ) );
  23. const tileRes = oututRes / sideSize;
  24.  
  25. for ( let id = 0; id < examples.length; id ++ ) {
  26.  
  27. const path = `./examples/screenshots/${ examples[ id ] }.png`;
  28.  
  29. if ( fs.existsSync( path ) ) {
  30.  
  31. const tile = ( await jimp.read( path ) ).resize( tileRes, tileRes );
  32. const i = id % sideSize;
  33. const j = Math.floor( id / sideSize );
  34. output.blit( tile, i * tileRes, j * tileRes );
  35. console.log( 'blit: ' + path );
  36.  
  37. }
  38.  
  39. }
  40.  
  41. const path = `./examples/screenshots/all_in_one.jpg`;
  42. output.quality( 90 ).write( path );
  43. printImage( output.bitmap, console );
  44. console.log( 'out: ' + path );
  45.  
  46. } ) ();
Add Comment
Please, Sign In to add comment