Improved editor

This commit is contained in:
Devine Lu Linvega
2019-07-26 14:42:04 +09:00
parent a45af143b1
commit 93c8e28c00
6 changed files with 43 additions and 8 deletions

View File

@@ -31,6 +31,7 @@ function Commander (ronin) {
}
this.run = (txt = this._input.value) => {
if (this._input.value.indexOf('$') > -1) { console.warn('$ is present.'); return }
ronin.bindings = {}
ronin.surface.maximize()
ronin.interpreter.run(txt)

View File

@@ -86,6 +86,7 @@ function Ronin () {
this.bindings[id](shape)
}
this.commander.capture()
this.surface.clearGuide()
this.surface.drawGuide(shape)
}
@@ -97,6 +98,7 @@ function Ronin () {
}
if (this.mouseOrigin) {
this.commander.commit(shape, false)
this.surface.clearGuide()
this.surface.drawGuide(shape)
}
}

View File

@@ -142,7 +142,13 @@ function Surface (ronin) {
if (isLine(shape)) {
this.context.drawImage(img, shape.a.x, shape.a.y, shape.b.x - shape.a.x, shape.b.y - shape.a.y)
} else if (isRect(shape)) {
this.context.drawImage(img, shape.x, shape.y, shape.w, img.height * (shape.w / img.width))
if (img.width > img.height) {
console.log('w bigger')
this.context.drawImage(img, shape.x, shape.y, shape.w, img.height * (shape.w / img.width))
} else {
console.log('h bigger')
this.context.drawImage(img, shape.x, shape.y, img.width * (shape.h / img.height), shape.h)
}
} else {
this.context.drawImage(img, shape.x, shape.y, img.width, img.height)
}
@@ -167,7 +173,6 @@ function Surface (ronin) {
}
this.drawGuide = function (shape, context = this.guide) {
this.clearGuide()
if (!shape) { return }
this.stroke(shape.rect || shape, 3, 'black', context)
if (shape.line) { this.stroke(shape.line, 3, 'black', context) }