diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index b317606..be617e2 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -91,7 +91,7 @@ function Cursor () { this.snapPos = function (pos) { return { x: clamp(step(pos.x, 15), 15, DOTGRID.tool.settings.size.width), - y: clamp(step(pos.y, 15), 15, DOTGRID.tool.settings.size.height + 15) + y: clamp(step(pos.y, 15), 15, DOTGRID.tool.settings.size.height) } } diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index a57da88..0bd8e4e 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -72,6 +72,28 @@ function Dotgrid (width, height) { }) } + this.save = function () { + if (DOTGRID.tool.length() < 1) { console.warn('Nothing to save'); return } + this.manager.toGRID(grab) + } + + this.export = function () { + if (DOTGRID.tool.length() < 1) { console.warn('Nothing to export'); return } + this.manager.toSVG(grab) + } + + this.render = function () { + if (DOTGRID.tool.length() < 1) { console.warn('Nothing to render'); return } + this.manager.toPNG({ width: DOTGRID.tool.settings.size.width * 2, height: DOTGRID.tool.settings.size.height * 2 }, grab) + } + + function grab (base64, name) { + const link = document.createElement('a') + link.setAttribute('href', base64) + link.setAttribute('download', name) + link.dispatchEvent(new MouseEvent(`click`, { bubbles: true, cancelable: true, view: window })) + } + // Basics this.getSize = function () { diff --git a/desktop/sources/scripts/manager.js b/desktop/sources/scripts/manager.js index 1595e34..01860f9 100644 --- a/desktop/sources/scripts/manager.js +++ b/desktop/sources/scripts/manager.js @@ -79,28 +79,4 @@ function Manager (dotgrid) { const file = new Blob([text], { type: 'text/plain' }) callback(URL.createObjectURL(file), 'export.grid') } - - // Helpers - - this.save = function () { - if (DOTGRID.tool.length() < 1) { console.warn('Nothing to save'); return } - this.toGRID(grab) - } - - this.export = function () { - if (DOTGRID.tool.length() < 1) { console.warn('Nothing to export'); return } - this.toSVG(grab) - } - - this.render = function () { - if (DOTGRID.tool.length() < 1) { console.warn('Nothing to render'); return } - this.toPNG({ width: DOTGRID.tool.settings.size.width * 2, height: DOTGRID.tool.settings.size.height * 2 }, grab) - } - - function grab (base64, name) { - const link = document.createElement('a') - link.setAttribute('href', base64) - link.setAttribute('download', name) - link.dispatchEvent(new MouseEvent(`click`, { bubbles: true, cancelable: true, view: window })) - } }