diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 96bb910..6fdf2b4 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -1,6 +1,6 @@ function Library (ronin) { - this.open = (path, w = 1, h = 1) => { - ronin.surface.open(path, { w, h }) + this.open = (path, callback) => { + ronin.surface.open(path, callback) return path } @@ -288,9 +288,9 @@ function Library (ronin) { b = b.toString() } if (a !== b) { - console.warn('failed ' + name, a) + console.warn('failed ' + name, a, b) } else { - console.log('passed ' + name, a, b) + console.log('passed ' + name, a) } return a === b } diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index dc9b72a..a2af93f 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -112,13 +112,17 @@ function Surface (ronin) { // IO - this.open = function (path, scale) { + this.open = function (path, callback = () => {}) { const img = new Image() img.src = path img.onload = () => { - ronin.log(`Image(${img.width}x${img.height}), scale:${scale.w}:${scale.h}`) - this.resize({ w: img.width * scale.w, h: img.height * scale.h }) - this.context.drawImage(img, 0, 0, img.width * scale.w, img.height * scale.h) + const rect = { w: img.width, h: img.height } + this.fitWindow(rect) + this.resize(rect) + this.context.drawImage(img, 0, 0, img.width, img.height) + if (typeof callback === 'function') { + callback() + } } } diff --git a/examples/include.lisp b/examples/include.lisp deleted file mode 100644 index f063b40..0000000 --- a/examples/include.lisp +++ /dev/null @@ -1,4 +0,0 @@ -( - (def value 12) - (def addOne (lambda (a) (add a 1))) -) \ No newline at end of file diff --git a/examples/open.lisp b/examples/open.lisp new file mode 100644 index 0000000..817d061 --- /dev/null +++ b/examples/open.lisp @@ -0,0 +1,13 @@ +; scale file +( + ; Filter + + (def filter-action + (lambda () (pixels + (frame) + saturation + 0.5) + )) + +(open (path "/Users/VillaMoirai/Desktop/clip.jpg") filter-action) +) \ No newline at end of file diff --git a/examples/run.lisp b/examples/run.lisp index 1d01a28..0954598 100644 --- a/examples/run.lisp +++ b/examples/run.lisp @@ -1,7 +1,5 @@ ( - (run "./include.lisp") - + (run "../examples/recursive.lisp") (echo value) - (echo (addOne value)) ) \ No newline at end of file diff --git a/examples/scale.lisp b/examples/scale.lisp deleted file mode 100644 index 5f86d20..0000000 --- a/examples/scale.lisp +++ /dev/null @@ -1,3 +0,0 @@ -; scale file - -(open ($path) 0.25 0.25) \ No newline at end of file