From 38f99b3ef8841e2311aac906c4e30e80f88eed56 Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 11 Mar 2020 16:30:59 +0900 Subject: [PATCH] * --- desktop/sources/scripts/library.js | 5 +++-- examples/pixels/import.lisp | 27 --------------------------- examples/pixels/normalize.lisp | 17 ++++++----------- examples/pixels/sharpen.lisp | 7 +++++++ 4 files changed, 16 insertions(+), 40 deletions(-) delete mode 100644 examples/pixels/import.lisp create mode 100644 examples/pixels/sharpen.lisp diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 61ead0b..9c4ff76 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -8,6 +8,7 @@ function Library (client) { this.open = async (name, scale = 1) => { // Import a graphic and scale canvas to fit. const img = client.cache.get(name) + if (!img) { client.log('No data for ' + name); return } const rect = this.rect(0, 0, img.width * scale, img.height * scale) await this.resize(rect.w, rect.h).then(this.import(name, rect)) return rect @@ -79,13 +80,13 @@ function Library (client) { // Frame - this.resize = (w = client.surface.bounds().w, h = client.surface.bounds().h, fit = true) => { // Resizes the canvas to target w and h, returns the rect. + this.resize = async (w = client.surface.bounds().w, h = client.surface.bounds().h, fit = true) => { // Resizes the canvas to target w and h, returns the rect. if (w === this['get-frame']().w && h === this['get-frame']().h) { return } const rect = { x: 0, y: 0, w, h } const a = document.createElement('img') const b = document.createElement('img') a.src = client.surface.el.toDataURL() - client.surface.resizeImage(a, b) + await client.surface.resizeImage(a, b) client.surface.resize(rect, fit) return client.surface.draw(b, rect) } diff --git a/examples/pixels/import.lisp b/examples/pixels/import.lisp deleted file mode 100644 index 6c778a3..0000000 --- a/examples/pixels/import.lisp +++ /dev/null @@ -1,27 +0,0 @@ -(clear) -(def hor-path "/Users/VillaMoirai/Desktop/hor.jpeg") -(def ver-path "/Users/VillaMoirai/Desktop/ver.jpg") -; rect -(import hor-path - (guide (rect 50 50 300 300))) - -(import hor-path - (guide (rect 350 50 350 200))) - -(import hor-path - (guide (line 700 50 1200 350))) - -(import hor-path - (guide (rect 1200 50 200 300))) - -(import ver-path - (guide (rect 50 350 300 300))) - -(import ver-path - (guide (rect 350 350 350 200))) - -(import ver-path - (guide (line 700 350 1200 700))) - -(import ver-path - (guide (rect 1200 350 200 300))) diff --git a/examples/pixels/normalize.lisp b/examples/pixels/normalize.lisp index 9ff7591..0f4bb11 100644 --- a/examples/pixels/normalize.lisp +++ b/examples/pixels/normalize.lisp @@ -1,11 +1,6 @@ -; Render script for a6000 -(clear) -(def photo-rect - (rect 0 0 - (div 4240 2) - (div 2400 2))) -(resize photo-rect:w photo-rect:h) -(import $path photo-rect) -(pixels normalize - (pick photo-rect)) -(export "export" "image/jpeg" 0.9) \ No newline at end of file +; Normalize photo colors + +(open $path 0.5) +(def average-color + (pick)) +(pixels normalize average-color) \ No newline at end of file diff --git a/examples/pixels/sharpen.lisp b/examples/pixels/sharpen.lisp new file mode 100644 index 0000000..3e0d7ef --- /dev/null +++ b/examples/pixels/sharpen.lisp @@ -0,0 +1,7 @@ +; sharpen photo + +(open $path 0.75) +(def average-color + (pick)) +(convolve + (sharpen)) \ No newline at end of file