Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
neauoire committed Mar 11, 2020
1 parent ca69d99 commit 38f99b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 40 deletions.
5 changes: 3 additions & 2 deletions desktop/sources/scripts/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
27 changes: 0 additions & 27 deletions examples/pixels/import.lisp

This file was deleted.

17 changes: 6 additions & 11 deletions examples/pixels/normalize.lisp
Original file line number Diff line number Diff line change
@@ -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)
; Normalize photo colors

(open $path 0.5)
(def average-color
(pick))
(pixels normalize average-color)
7 changes: 7 additions & 0 deletions examples/pixels/sharpen.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; sharpen photo

(open $path 0.75)
(def average-color
(pick))
(convolve
(sharpen))

0 comments on commit 38f99b3

Please sign in to comment.