Last active
August 27, 2018 06:34
-
-
Save Anna-Myzukina/6d5cb76d3f7f3428790b77e5f678c0b8 to your computer and use it in GitHub Desktop.
elementary-electron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var electron = require('electron') | |
electron.app.on('ready', function () { | |
var mainWindow = new electron.BrowserWindow({width: 600, height: 800}) | |
mainWindow.loadURL('file://' + __dirname + '/index.html') | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Hello World</h1> | |
<div id='visualization'></div> | |
<script type="text/javascript" src="index.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var remote = require('electron').remote | |
var fs = require('fs') | |
var image = require('lightning-image-poly') | |
var picture = require('cat-picture') | |
var src = picture.src | |
picture.remove() | |
var viz = new image('#visualization', null, [src], {hullAlgorithm: 'convex'}) | |
function save() { | |
remote.getCurrentWindow().webContents.printToPDF({ | |
portrait: true, | |
}, function(err, data) { | |
fs.writeFile('annotation.pdf', data, function(err) { | |
if (err) alert('error generating pdf! ' + err.message) | |
else alert('pdf saved!') | |
}) | |
}) | |
} | |
window.addEventListener('keydown', function(e) { | |
if (e.keyCode === 80) save() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment