mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 17:26:38 +02:00
♻️ Change pixel overlay rendering to use rasterizer
This commit is contained in:
parent
0496b1f4e3
commit
537435372a
2 changed files with 15 additions and 3 deletions
|
@ -61,7 +61,7 @@
|
|||
(.push ^js queue message))
|
||||
|
||||
(defn render
|
||||
"Renders a thumbnail."
|
||||
"Renders an SVG"
|
||||
[{:keys [data styles width] :as params}]
|
||||
(let [id (dm/str (uuid/next))
|
||||
payload #js {:data data :styles styles :width width}
|
||||
|
@ -81,6 +81,14 @@
|
|||
"failure" (rx/throw (js/Error. (unchecked-get msg "payload"))))))
|
||||
(rx/take 1))))
|
||||
|
||||
(defn render-node
|
||||
"Renders an SVG using a node"
|
||||
[{:keys [node styles width] :as params}]
|
||||
(let [width (or width (dom/get-attribute node "width"))
|
||||
styles (or styles "")
|
||||
data (dom/node->xml node)]
|
||||
(render {:data data :styles styles :width width})))
|
||||
|
||||
(defn init!
|
||||
"Initializes the thumbnail renderer."
|
||||
[]
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace.colors :as dwc]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.rasterizer :as thr]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.css-cursors :as cur]
|
||||
|
@ -166,7 +167,10 @@
|
|||
(fn []
|
||||
(let [img-node (mf/ref-val img-ref)
|
||||
svg-node (dom/get-element "render")]
|
||||
(->> (svg-as-data-url svg-node)
|
||||
(->> (rx/of {:node svg-node})
|
||||
(rx/mapcat thr/render-node)
|
||||
(rx/map wapi/create-uri)
|
||||
(rx/tap #(js/console.log %))
|
||||
(rx/subs (fn [uri]
|
||||
(obj/set! img-node "src" uri)))))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue