Fixed issue with view

This commit is contained in:
Devine Lu Linvega 2019-08-01 12:50:51 +09:00
parent 19ee5b726b
commit ce715a96bd
2 changed files with 10 additions and 10 deletions

View File

@ -152,13 +152,13 @@ function Commander (ronin) {
if (this.cache.indexOf('$') < 0) { return } if (this.cache.indexOf('$') < 0) { return }
const segs = this.cache.split('$') const segs = this.cache.split('$')
const words = segs[1].split(' ') const words = segs[1].split(' ')
const word = words[0].replace(/[^0-9a-z]/gi, '') const word = words[0].split(/[^A-Za-z]/)[0]
const append = words[0].indexOf('+') > -1 const append = words[0].indexOf('+') > -1
if (word === 'drag') { if (word === 'drag') {
this.cache = this.cache.replace('$drag', `(drag $rect $line)`) this.cache = this.cache.replace('$drag', `(drag $rect $line)`)
} else if (word === 'view') { } else if (word === 'view') {
this.cache = this.cache.replace('$view', `(drag $rect $rect)`) this.cache = this.cache.replace('$view', `(view $rect $rect)`)
} else if (word === 'poly') { } else if (word === 'poly') {
this.cache = this.cache.replace('$poly', `(poly $pos+)`) this.cache = this.cache.replace('$poly', `(poly $pos+)`)
} }

View File

@ -112,7 +112,7 @@ function Surface (ronin) {
this.traceLine = function (line, context) { this.traceLine = function (line, context) {
const positions = Object.values(line) const positions = Object.values(line)
const origin = positions.pop() const origin = positions.shift()
context.moveTo(origin.x, origin.y) context.moveTo(origin.x, origin.y)
for (pos of positions) { for (pos of positions) {
context.lineTo(pos.x, pos.y) context.lineTo(pos.x, pos.y)
@ -301,26 +301,26 @@ function Surface (ronin) {
} }
function isRect (shape) { function isRect (shape) {
return !isNaN(shape.x) && !isNaN(shape.y) && !isNaN(shape.w) && !isNaN(shape.h) return shape && !isNaN(shape.x) && !isNaN(shape.y) && !isNaN(shape.w) && !isNaN(shape.h)
} }
function isCircle (shape) { function isCircle (shape) {
return !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.r) return shape && !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.r)
} }
function isEllipse (shape) { function isEllipse (shape) {
return !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.rx) && !isNaN(shape.ry) return shape && !isNaN(shape.cx) && !isNaN(shape.cy) && !isNaN(shape.rx) && !isNaN(shape.ry)
} }
function isPos (shape) { function isPos (shape) {
return !isNaN(shape.x) && !isNaN(shape.y) return shape && !isNaN(shape.x) && !isNaN(shape.y)
} }
function isSvg (shape) { function isSvg (shape) {
return shape.d return shape && shape.d
} }
function isText (shape) { function isText (shape) {
return !isNaN(shape.x) && !isNaN(shape.y) && shape.p && shape.t && shape.f && shape.a return shape && !isNaN(shape.x) && !isNaN(shape.y) && shape.p && shape.t && shape.f && shape.a
} }
function isLine (shape) { function isLine (shape) {
const positions = Object.values(shape) const positions = Object.values(shape)
return !isNaN(positions[0].x) && !isNaN(positions[0].y) && !isNaN(positions[1].x) && !isNaN(positions[1].y) return positions[0] && positions[1] && !isNaN(positions[0].x) && !isNaN(positions[0].y) && !isNaN(positions[1].x) && !isNaN(positions[1].y)
} }
function fitRect (image, container) { function fitRect (image, container) {