From 61d34036cd0b13426b62900b7635f699617bb8c3 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 18 Jul 2019 19:33:32 +0900 Subject: [PATCH 1/3] Fixed issue with window resizing --- desktop/sources/scripts/library.js | 2 +- desktop/sources/scripts/lisp.js | 2 +- desktop/sources/scripts/surface.js | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index dafbfe9..6898c47 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -173,7 +173,7 @@ function Library (ronin) { for (let i = acc === undefined ? 1 : 0; i < length; i++) { result = await fn(result, arr[i], i, arr) } - return result; + return result } this.len = (item) => { // Returns the length of a list. diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index 74c1067..7459f97 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -73,7 +73,7 @@ function Lisp (input, lib) { return special[input[0].value](input, context) } const list = [] - for(let i = 0; i < input.length; i++) { + for (let i = 0; i < input.length; i++) { list.push(await interpret(input[i], context)) } return list[0] instanceof Function ? list[0].apply(undefined, list.slice(1)) : list diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index 6ee40ed..578f1d9 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -182,7 +182,8 @@ function Surface (ronin) { this.fitWindow = function (size) { const win = require('electron').remote.getCurrentWindow() const pad = { w: ronin.commander.isVisible === true ? 400 : 60, h: 60 } - win.setSize(size.w + pad.w, size.h + pad.h, true) + if (size.w < 10 || size.h < 10) { return } + win.setSize(Math.floor(size.w + pad.w), Math.floor(size.h + pad.h), true) } this.maximize = function () { @@ -229,7 +230,7 @@ function Surface (ronin) { context = canvas.getContext('2d') context.drawImage(tmp, 0, 0, cW, cH) dst.src = canvas.toDataURL(type, quality) - if (cW <= src.width || cH <= src.height) { return resolve()} + if (cW <= src.width || cH <= src.height) { return resolve() } tmp.src = dst.src return resolve() } From 4ab7d27367a5cb50f4c300def8c142a21e0755c4 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 18 Jul 2019 20:02:42 +0900 Subject: [PATCH 2/3] Added retina support. --- desktop/sources/scripts/surface.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index 578f1d9..36ab155 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -15,6 +15,7 @@ function Surface (ronin) { this._guide.addEventListener('mousedown', ronin.commander.onMouseDown, false) this._guide.addEventListener('mousemove', ronin.commander.onMouseMove, false) this._guide.addEventListener('mouseup', ronin.commander.onMouseUp, false) + // this.context.imageSmoothingEnabled = false this.context.scale(this.ratio, this.ratio) this.guide.scale(this.ratio, this.ratio) } @@ -164,12 +165,12 @@ function Surface (ronin) { console.log('Surface', `Resize: ${size.w}x${size.h}`) this.el.width = size.w this.el.height = size.h - this.el.style.width = size.w + 'px' - this.el.style.height = size.h + 'px' + this.el.style.width = (size.w / this.ratio) + 'px' + this.el.style.height = (size.h / this.ratio) + 'px' this._guide.width = size.w this._guide.height = size.h - this._guide.style.width = size.w + 'px' - this._guide.style.height = size.h + 'px' + this._guide.style.width = (size.w / this.ratio) + 'px' + this._guide.style.height = (size.h / this.ratio) + 'px' if (fit === true) { this.fitWindow(size) } @@ -183,11 +184,11 @@ function Surface (ronin) { const win = require('electron').remote.getCurrentWindow() const pad = { w: ronin.commander.isVisible === true ? 400 : 60, h: 60 } if (size.w < 10 || size.h < 10) { return } - win.setSize(Math.floor(size.w + pad.w), Math.floor(size.h + pad.h), true) + win.setSize(Math.floor((size.w / this.ratio) + pad.w), Math.floor((size.h / this.ratio) + pad.h), true) } this.maximize = function () { - this.resize({ x: 0, y: 0, w: window.innerWidth - 60, h: window.innerHeight - 60, t: 'rect' }) + this.resize({ x: 0, y: 0, w: (window.innerWidth * this.ratio) - 60, h: (window.innerHeight * this.ratio) - 60, t: 'rect' }) } this.onResize = function () { From 2d05a16f3d991312b41ae38765f39d4af2a8f698 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 18 Jul 2019 20:17:49 +0900 Subject: [PATCH 3/3] Fixed issue with jpg export --- desktop/sources/scripts/library.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 6898c47..2b0ff51 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -8,7 +8,7 @@ function Library (ronin) { this.export = (path, format = 'image/png', quality = 1.0) => { // Exports a graphic file with format. if (!path) { console.warn('Missing export path'); return path } var dataUrl = ronin.surface.el.toDataURL(format, quality) - const data = dataUrl.replace(/^data:image\/png;base64,/, '') + const data = dataUrl.replace(/^data:image\/png;base64,/, '').replace(/^data:image\/jpeg;base64,/, '') fs.writeFileSync(path, data, 'base64') return path }