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))
|
(.push ^js queue message))
|
||||||
|
|
||||||
(defn render
|
(defn render
|
||||||
"Renders a thumbnail."
|
"Renders an SVG"
|
||||||
[{:keys [data styles width] :as params}]
|
[{:keys [data styles width] :as params}]
|
||||||
(let [id (dm/str (uuid/next))
|
(let [id (dm/str (uuid/next))
|
||||||
payload #js {:data data :styles styles :width width}
|
payload #js {:data data :styles styles :width width}
|
||||||
|
@ -81,6 +81,14 @@
|
||||||
"failure" (rx/throw (js/Error. (unchecked-get msg "payload"))))))
|
"failure" (rx/throw (js/Error. (unchecked-get msg "payload"))))))
|
||||||
(rx/take 1))))
|
(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!
|
(defn init!
|
||||||
"Initializes the thumbnail renderer."
|
"Initializes the thumbnail renderer."
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.workspace.colors :as dwc]
|
[app.main.data.workspace.colors :as dwc]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
|
[app.main.rasterizer :as thr]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.css-cursors :as cur]
|
[app.main.ui.css-cursors :as cur]
|
||||||
|
@ -166,9 +167,12 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [img-node (mf/ref-val img-ref)
|
(let [img-node (mf/ref-val img-ref)
|
||||||
svg-node (dom/get-element "render")]
|
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]
|
(rx/subs (fn [uri]
|
||||||
(obj/set! img-node "src" uri)))))))
|
(obj/set! img-node "src" uri)))))))
|
||||||
|
|
||||||
handle-svg-change
|
handle-svg-change
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue