Fixed issue with guides
This commit is contained in:
parent
476d5d776c
commit
4d6ad70aad
desktop/sources/scripts
@ -118,26 +118,28 @@ function Commander (ronin) {
|
||||
this._input.value = this._input.value.replace('$path', `"${path}"`)
|
||||
}
|
||||
|
||||
this.commit = function (shape) {
|
||||
this.commit = function (shape, end = false) {
|
||||
if (this.cache.indexOf('$') < 0) { return }
|
||||
const segs = this.cache.split('$')
|
||||
const seg = segs[1]
|
||||
const words = seg.split(' ')
|
||||
const word = words[0]
|
||||
if (word === 'rect' && shape.rect) {
|
||||
if (word.substr(0, 4) === 'rect' && shape.rect) {
|
||||
const rect = shape.rect
|
||||
this._input.value = this.cache.replace('$rect', `(rect ${rect.x} ${rect.y} ${rect.w} ${rect.h})`)
|
||||
} else if (word === 'pos' && shape.pos) {
|
||||
} else if (word.substr(0, 3) === 'pos' && shape.pos) {
|
||||
const pos = shape.pos
|
||||
this._input.value = this.cache.replace('$pos', `(pos ${pos.x} ${pos.y})`)
|
||||
} else if (word === 'line' && shape.line) {
|
||||
} else if (word.substr(0, 4) === 'line' && shape.line) {
|
||||
const line = shape.line
|
||||
this._input.value = this.cache.replace('$line', `(line ${line.a.x} ${line.a.y} ${line.b.x} ${line.b.y})`)
|
||||
} else if (word === 'circle' && shape.circle) {
|
||||
} else if (word.substr(0, 6) === 'circle' && shape.circle) {
|
||||
const circle = shape.circle
|
||||
console.log(circle)
|
||||
this._input.value = this.cache.replace('$circle', `(circle ${circle.cx} ${circle.cy} ${circle.r})`)
|
||||
}
|
||||
if (end === true) {
|
||||
this.cache = this._input.value
|
||||
}
|
||||
}
|
||||
|
||||
// Display
|
||||
|
@ -96,7 +96,7 @@ function Ronin () {
|
||||
this.bindings[id](shape)
|
||||
}
|
||||
if (this.mouseOrigin) {
|
||||
this.commander.commit(shape)
|
||||
this.commander.commit(shape, false)
|
||||
this.surface.drawGuide(shape)
|
||||
}
|
||||
}
|
||||
@ -107,6 +107,9 @@ function Ronin () {
|
||||
if (this.bindings[id]) {
|
||||
this.bindings[id](shape)
|
||||
}
|
||||
if (this.mouseOrigin) {
|
||||
this.commander.commit(shape, true)
|
||||
}
|
||||
this.mouseOrigin = null
|
||||
this.surface.clearGuide()
|
||||
}
|
||||
|
@ -166,12 +166,13 @@ function Surface (ronin) {
|
||||
|
||||
this.drawGuide = function (shape, context = this.guide) {
|
||||
this.clearGuide()
|
||||
this.stroke(shape.rect, 3, 'black', context)
|
||||
this.stroke(shape.line, 3, 'black', context)
|
||||
this.stroke(shape.circle, 3, 'black', context)
|
||||
this.stroke(shape.rect, 1.5, 'white', context)
|
||||
this.stroke(shape.line, 1.5, 'white', context)
|
||||
this.stroke(shape.circle, 1.5, 'white', context)
|
||||
if (!shape) { return }
|
||||
this.stroke(shape.rect || shape, 3, 'black', context)
|
||||
if (shape.line) { this.stroke(shape.line, 3, 'black', context) }
|
||||
if (shape.circle) { this.stroke(shape.circle, 3, 'black', context) }
|
||||
this.stroke(shape.rect || shape, 1.5, 'white', context)
|
||||
if (shape.line) { this.stroke(shape.line, 1.5, 'white', context) }
|
||||
if (shape.circle) { this.stroke(shape.circle, 1.5, 'white', context) }
|
||||
}
|
||||
|
||||
this.clone = function (a, b) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user