From 55b1e54fad40c678f790ee7ce03489dddf7c767e Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 13 Jul 2019 16:27:32 +0900 Subject: [PATCH] Added scale and echo --- desktop/sources/scripts/library.js | 15 ++++++++++++--- desktop/sources/scripts/surface.js | 11 +---------- examples/scale.lisp | 3 +++ 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 examples/scale.lisp diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index da31614..cffc24b 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -9,11 +9,11 @@ function Library (ronin) { // Rects - this.pos = (x, y) => { + this.pos = (x, y, t = 'pos') => { return { x, y } } - this.size = (w, h) => { + this.size = (w, h, t = 'size') => { return { w, h } } @@ -26,13 +26,17 @@ function Library (ronin) { } this.frame = () => { - return { x: 0, y: 0, w: Math.floor(window.innerWidth / 2) - 15, h: Math.floor(window.innerHeight) - 30 } + return this.rect(0, 0, Math.floor(window.innerWidth / 2) - 15, Math.floor(window.innerHeight) - 30) } this.path = (path) => { return path } + this.scale = (rect, w, h) => { + return { x: rect.x, y: rect.y, w: rect.w * w, h: rect.h * h } + } + // Copy/Paste this.clone = (a, b) => { @@ -54,4 +58,9 @@ function Library (ronin) { ronin.surface.clear(rect) return rect } + + this.echo = function (any) { + console.log(any) + return any + } } diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index 25c548a..21d5327 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -4,8 +4,6 @@ function Surface (ronin) { this.ratio = window.devicePixelRatio this.context = this.el.getContext('2d') - this.guides = [] - this.install = function (host) { host.appendChild(this.el) window.addEventListener('resize', (e) => { this.onResize() }, false) @@ -21,9 +19,7 @@ function Surface (ronin) { } this.update = function () { - for (const id in this.guides) { - // this.drawRect(this.guides[id]) - } + } // Shape @@ -97,11 +93,6 @@ function Surface (ronin) { 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() - } - this.resize = function (size) { this.el.width = size.w this.el.height = size.h diff --git a/examples/scale.lisp b/examples/scale.lisp new file mode 100644 index 0000000..30b81a6 --- /dev/null +++ b/examples/scale.lisp @@ -0,0 +1,3 @@ +; scale file + +(echo (scale ($rect) 0.5 0.5)) \ No newline at end of file