diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 2914037..93c2b23 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -130,6 +130,8 @@ function Commander (ronin) { this._input.value = this._input.value.replace('$path', `"${path}"`) } + // Helpers + this.commit = function (shape, end = false, run = false) { if (this.cache.indexOf('$') < 0) { return } const segs = this.cache.split('$') @@ -151,6 +153,9 @@ function Commander (ronin) { } else if (word.substr(0, 4) === 'drag' && shape.line) { const rect = shape.rect this._input.value = this.cache.replace('$drag', `(drag (rect ${rect.x} ${rect.y} ${rect.w} ${rect.h}) $line)`) + } else if (word.substr(0, 4) === 'view' && shape.line) { + const rect = shape.rect + this._input.value = this.cache.replace('$view', `(view (rect ${rect.x} ${rect.y} ${rect.w} ${rect.h}) $rect)`) } if (end === true) { this.cache = this._input.value diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 4997969..0d7c418 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -155,7 +155,7 @@ function Library (ronin) { return [a, b] } - this.drag = (rect = this.frame(), line = this.line()) => { + this.drag = (rect = this.frame(), line = this.line()) => { // Drag a part of the canvas. const pos = { x: line.b.x - line.a.x, y: line.b.y - line.a.y } const crop = ronin.surface.getCrop(rect) ronin.surface.clear(rect) @@ -165,6 +165,13 @@ function Library (ronin) { ronin.surface.context.drawImage(crop, rect.x, rect.y) } + this.view = (a, b) => { // View a part of the canvas. + this.guide({ a: { x: a.x, y: a.y }, b: { x: b.x, y: b.y } }) + this.guide(a) + this.guide(b) + ronin.surface.context.drawImage(ronin.surface.getCrop(a), b.x, b.y, b.w, b.h) + } + this.theme = (variable, el = document.documentElement) => { // ex. (theme "f_main") -> :root { --f_main: "#fff" } return getComputedStyle(el).getPropertyValue(`--${variable}`)