Improved workshop example
This commit is contained in:
@@ -109,15 +109,18 @@ function Commander (ronin) {
|
||||
this.cache = this._input.value
|
||||
|
||||
this.capture = function () {
|
||||
if (this._input.value.indexOf('$') < 1) { return }
|
||||
console.log('capture')
|
||||
this.cache = this._input.value
|
||||
}
|
||||
|
||||
this.injectPath = function (path) {
|
||||
if (this._input.value.indexOf('$') < 1) { return }
|
||||
this._input.value = this._input.value.replace('$path', `"${path}"`)
|
||||
}
|
||||
|
||||
this.commit = function (shape) {
|
||||
if (this._input.value.indexOf('$') < 1) { return }
|
||||
console.log('inject')
|
||||
this._input.value = this.cache.replace('$rect', `(rect ${shape.x} ${shape.y} ${shape.w} ${shape.h})`).replace('$pos', `(pos ${shape.x} ${shape.y})`).replace('$line', `(line ${shape.a.x} ${shape.a.y} ${shape.b.x} ${shape.b.y})`)
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ function Ronin () {
|
||||
}
|
||||
|
||||
this.log = function (...msg) {
|
||||
this.commander.setStatus(msg.reduce((acc, val) => {
|
||||
return acc + JSON.stringify(val).replace(/\"/g,'').trim() + ' '
|
||||
this.commander.setStatus(msg.reduce((acc, val) => {
|
||||
return acc + JSON.stringify(val).replace(/\"/g, '').trim() + ' '
|
||||
}, ''))
|
||||
}
|
||||
|
||||
@@ -100,12 +100,13 @@ function Ronin () {
|
||||
}
|
||||
|
||||
this.onMouseUp = (e, id = 'mouse-up') => {
|
||||
this.mouseTouch = null
|
||||
const shape = this.makeMouseOffset({ x: e.offsetX, y: e.offsetY }, id)
|
||||
this.mouseTouch = null
|
||||
if (this.bindings[id]) {
|
||||
this.bindings[id](shape)
|
||||
}
|
||||
this.surface.clearGuide()
|
||||
console.log(this.bindings)
|
||||
}
|
||||
|
||||
this.makeMouseOffset = (pos, type) => {
|
||||
|
||||
Reference in New Issue
Block a user