Reverted io

This commit is contained in:
Devine Lu Linvega 2019-01-10 08:45:50 +12:00
parent 24a7b76254
commit 03cb438b9b
3 changed files with 23 additions and 25 deletions

View File

@ -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)
}
}

View File

@ -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 () {

View File

@ -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 }))
}
}