Merge branch 'master' of github.com:hundredrabbits/Ronin
This commit is contained in:
commit
9255568cc8
@ -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
|
||||
}
|
||||
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
@ -182,11 +183,12 @@ 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 / 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 () {
|
||||
@ -229,7 +231,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()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user