mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 06:01:37 +02:00
♻️ Change pixel overlay inner workings
This commit is contained in:
parent
537435372a
commit
9ce8c2d580
4 changed files with 88 additions and 141 deletions
|
@ -178,22 +178,35 @@
|
|||
|
||||
(constantly nil)))))
|
||||
|
||||
(defn- render
|
||||
"Renders a thumbnail using it's SVG and returns an ArrayBuffer of the image."
|
||||
(defn- render-image-bitmap
|
||||
"Renders a thumbnail using it's SVG and returns an ImageBitmap of the image."
|
||||
[payload]
|
||||
(let [data (unchecked-get payload "data")
|
||||
styles (unchecked-get payload "styles")
|
||||
width (d/nilv (unchecked-get payload "width") 300)]
|
||||
width (d/nilv (unchecked-get payload "width") 300)
|
||||
quality (d/nilv (unchecked-get payload "quality") "medium")]
|
||||
(->> (svg-prepare data styles width)
|
||||
(rx/map #(wapi/create-blob % "image/svg+xml"))
|
||||
(rx/map wapi/create-uri)
|
||||
(rx/mapcat (fn [uri]
|
||||
(->> (create-image uri)
|
||||
(rx/mapcat #(wapi/create-image-bitmap % #js {:resizeWidth width
|
||||
:resizeQuality "medium"}))
|
||||
(rx/tap #(wapi/revoke-uri uri)))))
|
||||
:resizeQuality quality}))
|
||||
(rx/tap #(wapi/revoke-uri uri))))))))
|
||||
|
||||
(rx/mapcat bitmap->blob))))
|
||||
(defn- render-blob
|
||||
"Renders a thumbnail using it's SVG and returns a Blob of the image."
|
||||
[payload]
|
||||
(->> (render-image-bitmap payload)
|
||||
(rx/mapcat bitmap->blob)))
|
||||
|
||||
(defn- render
|
||||
"Renders a thumbnail and returns a stream."
|
||||
[payload]
|
||||
(let [result (d/nilv (unchecked-get payload "result") "blob")]
|
||||
(case result
|
||||
"image-bitmap" (render-image-bitmap payload)
|
||||
(render-blob payload))))
|
||||
|
||||
(defn- on-message
|
||||
"Handles messages from the main thread."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue