Added clone function
This commit is contained in:
@@ -17,7 +17,7 @@ function Commander (ronin) {
|
||||
}
|
||||
|
||||
this.start = function () {
|
||||
this._status.textContent = 'Idle, RUN(cmd+enter).'
|
||||
this._status.textContent = 'Idle. (zoom 100%)'
|
||||
this._input.focus()
|
||||
this.run()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,14 @@ function Library (ronin) {
|
||||
|
||||
// Rects
|
||||
|
||||
this.pos = (x, y) => {
|
||||
return { x, y }
|
||||
}
|
||||
|
||||
this.size = (w, h) => {
|
||||
return { w, h }
|
||||
}
|
||||
|
||||
this.rect = (x, y, w, h) => {
|
||||
return { x, y, w, h }
|
||||
}
|
||||
@@ -12,17 +20,23 @@ function Library (ronin) {
|
||||
return { x: 0, y: 0, w: Math.floor(window.innerWidth / 2) - 15, h: Math.floor(window.innerHeight) - 30 }
|
||||
}
|
||||
|
||||
this.stroke = (rect, thickness, color) => {
|
||||
// Copy/Paste
|
||||
|
||||
this.clone = (a, b) => {
|
||||
ronin.surface.clone(a, b)
|
||||
}
|
||||
|
||||
this.stroke = (rect = this.frame(), thickness, color) => {
|
||||
ronin.surface.stroke(rect, thickness, color)
|
||||
return rect
|
||||
}
|
||||
|
||||
this.fill = (rect = this.frame(), thickness, color) => {
|
||||
ronin.surface.fill(rect, thickness, color)
|
||||
this.fill = (rect = this.frame(), color) => {
|
||||
ronin.surface.fill(rect, color)
|
||||
return rect
|
||||
}
|
||||
|
||||
this.clear = (rect) => {
|
||||
this.clear = (rect = this.frame()) => {
|
||||
ronin.surface.clear(rect)
|
||||
return rect
|
||||
}
|
||||
|
||||
@@ -35,23 +35,26 @@ function Surface (ronin) {
|
||||
this.context.closePath()
|
||||
}
|
||||
|
||||
this.fill = (rect, width, color) => {
|
||||
this.fill = (rect, color) => {
|
||||
this.context.beginPath()
|
||||
this.context.moveTo(rect.x, rect.y)
|
||||
this.context.lineTo(rect.x + rect.w, rect.y)
|
||||
this.context.lineTo(rect.x + rect.w, rect.y + rect.h)
|
||||
this.context.lineTo(rect.x, rect.y + rect.h)
|
||||
this.context.lineTo(rect.x, rect.y)
|
||||
this.context.lineWidth = width
|
||||
this.context.fillStyle = color
|
||||
this.context.fill()
|
||||
this.context.closePath()
|
||||
}
|
||||
|
||||
this.clear = function (rect) {
|
||||
this.clear = function (rect = this.getRect()) {
|
||||
this.context.clearRect(rect.x, rect.y, rect.w, rect.h)
|
||||
}
|
||||
|
||||
this.clone = function (a, b) {
|
||||
this.context.drawImage(this.el, a.x, a.y, a.w, a.h, b.x, b.y, b.w, b.h)
|
||||
}
|
||||
|
||||
this.addGuide = function (rect) {
|
||||
this.guides.push(rect)
|
||||
this.update()
|
||||
@@ -73,6 +76,6 @@ function Surface (ronin) {
|
||||
}
|
||||
|
||||
this.getRect = function () {
|
||||
return { x: 0, y: 0, w: Math.floor(window.innerWidth / 2) - 15, h: Math.floor(window.innerHeight) - 30 }
|
||||
return { x: 0, y: 0, w: Math.floor(window.innerWidth / 2) - 30, h: Math.floor(window.innerHeight) - 60 }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user