2018-07-22 22:34:35 +00:00
|
|
|
/**
|
|
|
|
* Render the frames into PNG images
|
|
|
|
* An electron app, takes one command line argument `step`
|
|
|
|
*
|
|
|
|
* @author Mohammad Fares <faressoft.com@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
var path = require('path'),
|
|
|
|
app = require('electron').app,
|
|
|
|
BrowserWindow = require('electron').BrowserWindow,
|
2018-07-24 08:00:21 +00:00
|
|
|
ipcMain = require('electron').ipcMain,
|
|
|
|
os = require('os');
|
2018-07-22 22:34:35 +00:00
|
|
|
|
|
|
|
// Set as global to be read by the web page
|
|
|
|
global.step = process.argv[2] || 1;
|
|
|
|
|
|
|
|
// Set the display scale factor to 1
|
|
|
|
app.commandLine.appendSwitch('force-device-scale-factor', 1);
|
|
|
|
|
2018-07-24 08:00:21 +00:00
|
|
|
// Hide the Dock for macOS
|
|
|
|
if (os.platform() == 'darwin') {
|
|
|
|
app.dock.hide();
|
|
|
|
}
|
|
|
|
|
2018-07-22 22:34:35 +00:00
|
|
|
// When the app is ready
|
|
|
|
app.on('ready', createWindow);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a hidden browser window and load the rendering page
|
|
|
|
*/
|
|
|
|
function createWindow() {
|
|
|
|
|
|
|
|
// Create a browser window
|
2018-07-25 13:23:01 +00:00
|
|
|
var win = new BrowserWindow({show: false, width: 8000, height: 8000});
|
2018-07-22 22:34:35 +00:00
|
|
|
|
|
|
|
// Load index.html
|
|
|
|
win.loadURL('file://' + __dirname + '/index.html');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A callback function for the event:
|
|
|
|
* When a frame is captured
|
|
|
|
*
|
2018-07-25 13:46:32 +00:00
|
|
|
* @param {Object} event
|
2018-07-22 22:34:35 +00:00
|
|
|
* @param {Number} recordIndex
|
|
|
|
*/
|
2018-07-25 13:46:32 +00:00
|
|
|
ipcMain.on('captured', function(event, recordIndex) {
|
2018-07-22 22:34:35 +00:00
|
|
|
|
|
|
|
console.log(recordIndex);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A callback function for the event:
|
|
|
|
* When something unexpected happened
|
|
|
|
*
|
|
|
|
* @param {String} errorMsg
|
|
|
|
*/
|
|
|
|
ipcMain.on('error', function(errorMsg) {
|
|
|
|
|
|
|
|
console.error(errorMsg);
|
|
|
|
|
|
|
|
});
|