*
This commit is contained in:
parent
ffc409e173
commit
93289969f3
@ -1,23 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "Dotgrid",
|
"name": "Dotgrid",
|
||||||
"productName": "Dotgrid",
|
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"lint": "eslint --ignore-path ../.gitignore .",
|
|
||||||
"fix": "standard --fix",
|
"fix": "standard --fix",
|
||||||
"clean": "rm -r ~/Desktop/Dotgrid-darwin-x64/ ; rm -r ~/Desktop/Dotgrid-linux-x64/ ; rm -r ~/Desktop/Dotgrid-win32-x64/ ; rm -r ~/Desktop/Dotgrid-linux-armv7l/ ; echo 'cleaned build location'",
|
"clean": "rm -r ~/Documents/Dotgrid-darwin-x64/ ; rm -r ~/Documents/Dotgrid-linux-x64/ ; rm -r ~/Documents/Dotgrid-win32-x64/ ; echo 'cleaned build location'",
|
||||||
"build_osx": "electron-packager . Dotgrid --platform=darwin --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
|
"build_osx": "electron-packager . Dotgrid --platform=darwin --arch=x64 --out ~/Documents/ --overwrite --icon=icon.icns ; echo 'Built for OSX'",
|
||||||
"build_linux": "electron-packager . Dotgrid --platform=linux --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
|
"build_linux": "electron-packager . Dotgrid --platform=linux --arch=x64 --out ~/Documents/ --overwrite --icon=icon.ico ; echo 'Built for LINUX'",
|
||||||
"build_win": "electron-packager . Dotgrid --platform=win32 --arch=x64 --out ~/Desktop/ --overwrite --icon=icon.ico ; echo 'Built for WIN'",
|
"build_win": "electron-packager . Dotgrid --platform=win32 --arch=x64 --out ~/Documents/ --overwrite --icon=icon.ico ; echo 'Built for WIN'",
|
||||||
"build": "npm run clean ; npm run build_osx ; npm run build_linux ; npm run build_win",
|
"build": "npm run clean ; npm run build_osx ; npm run build_linux ; npm run build_win",
|
||||||
"push_osx": "~/butler push ~/Desktop/Dotgrid-darwin-x64/ hundredrabbits/dotgrid:osx-64",
|
"push_osx": "~/Applications/butler push ~/Documents/Dotgrid-darwin-x64/ hundredrabbits/ronin:osx-64",
|
||||||
"push_linux": "~/butler push ~/Desktop/Dotgrid-linux-x64/ hundredrabbits/dotgrid:linux-64",
|
"push_linux": "~/Applications/butler push ~/Documents/Dotgrid-linux-x64/ hundredrabbits/ronin:linux-64",
|
||||||
"push_win": "~/butler push ~/Desktop/Dotgrid-win32-x64/ hundredrabbits/dotgrid:windows-64",
|
"push_win": "~/Applications/butler push ~/Documents/Dotgrid-win32-x64/ hundredrabbits/ronin:windows-64",
|
||||||
"push_theme": "~/butler push ~/Github/HundredRabbits/Themes/themes/ hundredrabbits/dotgrid:themes",
|
"status": "~/Applications/butler status hundredrabbits/ronin",
|
||||||
"push_status": "~/butler status hundredrabbits/dotgrid",
|
"push": "npm run build ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run status"
|
||||||
"push": "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^7.0.0",
|
"electron": "^7.0.0",
|
||||||
|
@ -21,8 +21,8 @@ function Dotgrid () {
|
|||||||
this.acels = new Acels()
|
this.acels = new Acels()
|
||||||
this.theme = new Theme()
|
this.theme = new Theme()
|
||||||
this.history = new History()
|
this.history = new History()
|
||||||
|
this.source = new Source()
|
||||||
|
|
||||||
this.source = new Source(this)
|
|
||||||
this.manager = new Manager(this)
|
this.manager = new Manager(this)
|
||||||
this.renderer = new Renderer(this)
|
this.renderer = new Renderer(this)
|
||||||
this.tool = new Tool(this)
|
this.tool = new Tool(this)
|
||||||
@ -44,9 +44,9 @@ function Dotgrid () {
|
|||||||
window.addEventListener('drop', this.onDrop)
|
window.addEventListener('drop', this.onDrop)
|
||||||
|
|
||||||
this.acels.set('File', 'New', 'CmdOrCtrl+N', () => { this.source.new() })
|
this.acels.set('File', 'New', 'CmdOrCtrl+N', () => { this.source.new() })
|
||||||
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.save('export.grid', this.tool.export(), 'text/plain') })
|
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.download('dotgrid','grid' , this.tool.export(), 'text/plain') })
|
||||||
this.acels.set('File', 'Export Vector', 'CmdOrCtrl+E', () => { this.source.download('export.svg', this.manager.toString(), 'image/svg+xml') })
|
this.acels.set('File', 'Export Vector', 'CmdOrCtrl+E', () => { this.source.download('dotgrid','svg', this.manager.toString(), 'image/svg+xml') })
|
||||||
this.acels.set('File', 'Export Image', 'CmdOrCtrl+Shift+E', () => { this.manager.toPNG(this.tool.settings.size, (dataUrl) => { this.source.download('export.png', dataUrl, 'image/png') }) })
|
this.acels.set('File', 'Export Image', 'CmdOrCtrl+Shift+E', () => { this.manager.toPNG(this.tool.settings.size, (dataUrl) => { this.source.download('dotgrid','png', dataUrl, 'image/png') }) })
|
||||||
this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('grid', this.whenOpen) })
|
this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('grid', this.whenOpen) })
|
||||||
this.acels.set('File', 'Revert', 'CmdOrCtrl+W', () => { this.source.revert() })
|
this.acels.set('File', 'Revert', 'CmdOrCtrl+W', () => { this.source.revert() })
|
||||||
this.acels.set('History', 'Undo', 'CmdOrCtrl+Z', () => { this.history.undo() })
|
this.acels.set('History', 'Undo', 'CmdOrCtrl+Z', () => { this.history.undo() })
|
||||||
|
@ -35,9 +35,9 @@ function Source () {
|
|||||||
this.saveAs(name, content, type, callback)
|
this.saveAs(name, content, type, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveAs = (name, content, type = 'text/plain', callback) => {
|
this.saveAs = (name,ext, content, type = 'text/plain', callback) => {
|
||||||
console.log('Source', 'Save new file..')
|
console.log('Source', 'Save new file..')
|
||||||
this.download(name, content, type, callback)
|
this.download(name, ext,content, type, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.revert = () => {
|
this.revert = () => {
|
||||||
@ -55,10 +55,9 @@ function Source () {
|
|||||||
reader.readAsText(file, 'UTF-8')
|
reader.readAsText(file, 'UTF-8')
|
||||||
}
|
}
|
||||||
|
|
||||||
this.download = (name, content, type, settings = 'charset=utf-8') => {
|
this.download = (name, ext,content, type, settings = 'charset=utf-8') => {
|
||||||
console.info('Source', `Downloading ${name}(${type})`)
|
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.setAttribute('download', name)
|
link.setAttribute('download', `${name}-${timestamp()}.${ext}`)
|
||||||
if (type === 'image/png' || type === 'image/jpeg') {
|
if (type === 'image/png' || type === 'image/jpeg') {
|
||||||
link.setAttribute('href', content)
|
link.setAttribute('href', content)
|
||||||
} else {
|
} else {
|
||||||
@ -66,4 +65,10 @@ function Source () {
|
|||||||
}
|
}
|
||||||
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
|
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function timestamp (d = new Date(), e = new Date(d)) {
|
||||||
|
const ms = e - d.setHours(0, 0, 0, 0)
|
||||||
|
return (ms / 8640 / 10000).toFixed(6).substr(2, 6)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,9 +206,9 @@ function Tool (dotgrid) {
|
|||||||
this.source = function (type) {
|
this.source = function (type) {
|
||||||
if (type === 'grid') { dotgrid.renderer.toggle() }
|
if (type === 'grid') { dotgrid.renderer.toggle() }
|
||||||
if (type === 'open') { dotgrid.source.open('grid', dotgrid.whenOpen) }
|
if (type === 'open') { dotgrid.source.open('grid', dotgrid.whenOpen) }
|
||||||
if (type === 'save') { dotgrid.source.save('export.grid', dotgrid.tool.export(), 'text/plain') }
|
if (type === 'save') { dotgrid.source.download('dotgrid','grid', dotgrid.tool.export(), 'text/plain') }
|
||||||
if (type === 'export') { dotgrid.source.download('export.svg', dotgrid.manager.toString(), 'image/svg+xml') }
|
if (type === 'export') { dotgrid.source.download('dotgrid','svg', dotgrid.manager.toString(), 'image/svg+xml') }
|
||||||
if (type === 'render') { dotgrid.manager.toPNG(dotgrid.tool.settings.size, (dataUrl) => { dotgrid.source.download('export.png', dataUrl, 'image/png') }) }
|
if (type === 'render') { dotgrid.manager.toPNG(dotgrid.tool.settings.size, (dataUrl) => { dotgrid.source.download('dotgrid','png', dataUrl, 'image/png') }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
this.canAppend = function (content, index = this.index) {
|
this.canAppend = function (content, index = this.index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user