Added (view) to the library
This commit is contained in:
parent
b828980f34
commit
d9fe19c04b
@ -130,6 +130,8 @@ function Commander (ronin) {
|
|||||||
this._input.value = this._input.value.replace('$path', `"${path}"`)
|
this._input.value = this._input.value.replace('$path', `"${path}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
this.commit = function (shape, end = false, run = false) {
|
this.commit = function (shape, end = false, run = false) {
|
||||||
if (this.cache.indexOf('$') < 0) { return }
|
if (this.cache.indexOf('$') < 0) { return }
|
||||||
const segs = this.cache.split('$')
|
const segs = this.cache.split('$')
|
||||||
@ -151,6 +153,9 @@ function Commander (ronin) {
|
|||||||
} else if (word.substr(0, 4) === 'drag' && shape.line) {
|
} else if (word.substr(0, 4) === 'drag' && shape.line) {
|
||||||
const rect = shape.rect
|
const rect = shape.rect
|
||||||
this._input.value = this.cache.replace('$drag', `(drag (rect ${rect.x} ${rect.y} ${rect.w} ${rect.h}) $line)`)
|
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) {
|
if (end === true) {
|
||||||
this.cache = this._input.value
|
this.cache = this._input.value
|
||||||
|
@ -155,7 +155,7 @@ function Library (ronin) {
|
|||||||
return [a, b]
|
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 pos = { x: line.b.x - line.a.x, y: line.b.y - line.a.y }
|
||||||
const crop = ronin.surface.getCrop(rect)
|
const crop = ronin.surface.getCrop(rect)
|
||||||
ronin.surface.clear(rect)
|
ronin.surface.clear(rect)
|
||||||
@ -165,6 +165,13 @@ function Library (ronin) {
|
|||||||
ronin.surface.context.drawImage(crop, rect.x, rect.y)
|
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) => {
|
this.theme = (variable, el = document.documentElement) => {
|
||||||
// ex. (theme "f_main") -> :root { --f_main: "#fff" }
|
// ex. (theme "f_main") -> :root { --f_main: "#fff" }
|
||||||
return getComputedStyle(el).getPropertyValue(`--${variable}`)
|
return getComputedStyle(el).getPropertyValue(`--${variable}`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user