Implemented #21

This commit is contained in:
Devine Lu Linvega 2018-05-13 09:50:19 +12:00
parent c40b266076
commit db872c033c
4 changed files with 22 additions and 9 deletions

View File

@ -29,10 +29,10 @@ app.win = null;
app.on('ready', () =>
{
app.win = new BrowserWindow({width: 400, height: 420, minWidth: 400, minHeight: 420, backgroundColor:"#000", frame:false, autoHideMenuBar: true, icon: __dirname + '/icon.ico'})
app.win.loadURL(`file://${__dirname}/sources/index.html`);
app.win = new BrowserWindow({width: 400, height: 420, minWidth: 400, minHeight: 420, backgroundColor:"#000", frame:false, autoHideMenuBar: true, icon: __dirname + '/icon.ico',webPreferences: {zoomFactor: 1.0}})
app.win.loadURL(`file://${__dirname}/sources/index.html`);
app.win.on('closed', () => {
win = null
app.quit()

View File

@ -21,6 +21,7 @@
<body>
<div id="app">
<script>
const webFrame = require('electron').webFrame
const {dialog,app} = require('electron').remote;
const fs = require('fs');

View File

@ -77,6 +77,8 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.controller.add("default","View","Tools",() => { dotgrid.interface.toggle(); },"U");
this.controller.add("default","View","Grid",() => { dotgrid.guide.toggle(); },"H");
this.controller.add("default","View","Zoom Reset",() => { dotgrid.set_zoom(1.0) },"-");
this.controller.add("default","View","Zoom 150%",() => { dotgrid.set_zoom(1.5) },"Plus");
this.controller.add("default","Mode","Picker",() => { dotgrid.picker.start(); },"CmdOrCtrl+P");
@ -343,16 +345,16 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
// Basics
this.set_size = function(size = {width:300,height:300},interface = true)
this.set_size = function(size = {width:300,height:300},interface = true,scale = 1)
{
size = { width:clamp(parseInt(size.width/15)*15,100,1000),height:clamp(parseInt(size.height/15)*15,100,1000)}
size = { width:clamp(parseInt(size.width/15)*15,120,1000),height:clamp(parseInt(size.height/15)*15,120,1000)}
var win = require('electron').remote.getCurrentWindow();
win.setSize(size.width+100,size.height+100+(interface ? 10 : 0),true);
this.tool.settings.size.width = size.width
this.tool.settings.size.height = size.height
var win = require('electron').remote.getCurrentWindow();
win.setSize((size.width+100)*scale,(size.height+100+(interface ? 10 : 0))*scale,true);
this.grid_x = size.width/15
this.grid_y = size.height/15
@ -365,6 +367,12 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
dotgrid.guide.refresh();
}
this.set_zoom = function(scale)
{
this.set_size({width:this.tool.settings.size.width,height:this.tool.settings.size.height},true,scale)
webFrame.setZoomFactor(scale)
}
// Draw
this.reset = function()

View File

@ -48,10 +48,14 @@ function Renderer()
this.layer_3.setAttribute("d",paths[2])
}
this.to_png = function(size = {width:1280,height:1280},callback = dotgrid.render)
this.to_png = function(size = dotgrid.tool.settings.size,callback = dotgrid.render)
{
this.refresh();
// Upscale
size.width *= 2
size.height *= 2
var xml = new XMLSerializer().serializeToString(this.svg_el);
var svg64 = btoa(xml);
var b64Start = 'data:image/svg+xml;base64,';