Skip to content

Instantly share code, notes, and snippets.

@deemru deemru/shot.js
Created Nov 12, 2018

Embed
What would you like to do?
Waves Platform Mainnet (1 .. 1257702)
// https://github.com/deemru/w8io/tree/15842edd4235bd3eabc127deac61195257e351ba
// https://github.com/GoogleChrome/puppeteer
// ffmpeg -framerate 30 -i "w8io_(%%d).png" -c:v libx264 -preset slow -crf 16 -vf fps=30 _w8io.mp4
// https://www.youtube.com/watch?v=n7A-KQ15ynY
var promises = [];
var maxBrowsers = 8;
var maxPromises = maxBrowsers;
showtime();
async function doshot( fs, browser, n, res, block )
{
var w8url = 'http://127.0.0.1:81/w8io/GENERATORS/' + res + '/' + block;
var w8file = 'w8io_(' + n + ').png';
if( fs.existsSync( w8file ) )
{
console.log( w8url + ' (skip)' );
return;
}
console.log( w8url );
var page = await browser.newPage();
await page.setViewport( { width: 3840, height: 2160 } );
await page.goto( w8url, { timeout: 0 } );
await page.screenshot( { path: w8file } );
await page.close();
console.log( w8file );
}
async function workit( work, finalize = false )
{
promises.push( work );
if( finalize || promises.length >= maxPromises )
{
await Promise.all( promises );
promises = [];
}
}
async function showtime()
{
var fs = require('fs');
var puppeteer = require( 'puppeteer' );
var browsers = [];
for( i = 0; i < maxBrowsers; i++ )
browsers[i] = await puppeteer.launch();
var i;
var w8url;
var w8file;
var n = 0;
var c = 300;
var Q = 128;
var res = 128;
var res_this = 0;
var speed = 1;
var block = 0;
// GENESIS (128)
{
c = 300;
for( i = 0; i < c; i++ )
{
n++;
console.log( n );
block++;
await workit( doshot( fs, browsers[i % maxBrowsers], n, res, block ) );
}
}
// compactify
{
c = 120 + 480;
for( i = 0; i < c; i++ )
{
n++;
console.log( n );
res = res + ( res / 128 ) * Math.min( 1, ( i + 1 ) / 120 );
speed = res / Q + res / Q * Math.min( 1, ( i + 1 ) / 120 );
block = block + speed;
await workit( doshot( fs, browsers[i % maxBrowsers], n, Math.round( res ), Math.round( block ) ) );
}
}
// >> 10112/79
{
c = 120;
for( i = 0; i < c; i++ )
{
n++;
console.log( n );
res_this = res + ( i + 1 ) / c * ( 10112 - res );
speed = res_this / Q * ( 2 - ( i + 1 ) / c );
block += speed;
await workit( doshot( fs, browsers[i % maxBrowsers], n, Math.round( res_this ), Math.round( block ) ) );
}
res = res_this;
}
// 10112 ( >> 1257746 )
{
res = Math.round( res );
block = Math.round( block );
c = Math.floor( ( 1257746 - block ) / 79 );
for( i = 0; i < c; i++ )
{
n++;
console.log( n );
block += speed;
await workit( doshot( fs, browsers[i % maxBrowsers], n, res, block ) );
}
}
await workit( null, true );
console.log( 'SUCCESS' );
for( i = 0; i < maxBrowsers; i++ )
await browsers[i].close();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.