-
Notifications
You must be signed in to change notification settings - Fork 0
/
page2.html
41 lines (41 loc) · 1.49 KB
/
page2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>action page 2</title>
<script type="text/javascript" src="lib.js"></script>
<script type="text/javascript">
require('canvg');
var ipcRenderer = require('electron').ipcRenderer;
function startPotrace(path, uuid) {
Potrace.loadFromFS(path, function(){
var svg = Potrace.getSVG(1, null);
ipcRenderer.send(('potrace'+uuid), svg, 2);
});
};
ipcRenderer.on('svg', function (event, code, width, height, format, uuid, potrace) {
if(typeof(format) === "undefined"){
format = 'image/png';
}
var canvas = document.getElementById('canvas');
if(width){
canvas.width = width;
canvas.height = height;
canvg('canvas', code, {ignoreDimensions: true, scaleWidth: width, scaleHeight: height});
}else{
canvg('canvas', code);
}
if (potrace) {
startPotrace(canvas.toDataURL(format), uuid);
} else {
ipcRenderer.send(('svg'+uuid), canvas.toDataURL(format), 2);
}
});
window.onerror = function(error, url, line) {
ipcRenderer.send('windowError', error, 2);
};
</script>
</head>
<body>
<div id="container"><canvas id="canvas"></canvas></div>
</body>
</html>