mirror of
https://github.com/penpot/penpot.git
synced 2026-08-06 21:08:34 +00:00
Basic multiple fill support
This commit is contained in:
parent
189e6b31d0
commit
77f07f9751
@ -60,27 +60,29 @@
|
|||||||
|
|
||||||
(defn render-gl
|
(defn render-gl
|
||||||
[gl objects vbox]
|
[gl objects vbox]
|
||||||
(.clearColor gl 1.0 0.0 1.0 0.5)
|
(.clearColor gl 1.0 0.0 1.0 0)
|
||||||
(.clear gl (.-COLOR_BUFFER_BIT gl))
|
(.clear gl (.-COLOR_BUFFER_BIT gl))
|
||||||
|
|
||||||
(.viewport gl 0 0 (.-width (.-canvas gl)) (.-height (.-canvas gl)))
|
(.viewport gl 0 0 (.-width (.-canvas gl)) (.-height (.-canvas gl)))
|
||||||
|
|
||||||
(.useProgram gl (.get programs "default"))
|
(.useProgram gl (.get programs "default"))
|
||||||
(println "---------------> vbox" (:x vbox) (:width vbox) (:y vbox) (:height vbox))
|
|
||||||
(.uniform4f gl (.getUniformLocation gl (.get programs "default") "u_vbox") (:x vbox) (:y vbox) (:width vbox) (:height vbox))
|
(.uniform4f gl (.getUniformLocation gl (.get programs "default") "u_vbox") (:x vbox) (:y vbox) (:width vbox) (:height vbox))
|
||||||
|
|
||||||
|
(.enable gl (.-BLEND gl))
|
||||||
|
(.blendFunc gl (.-SRC_ALPHA gl) (.-ONE_MINUS_SRC_ALPHA gl))
|
||||||
|
|
||||||
(doseq [[_ object] objects]
|
(doseq [[_ object] objects]
|
||||||
(let [selrect (:selrect object)
|
(let [selrect (:selrect object)
|
||||||
x (:x selrect)
|
x (:x selrect)
|
||||||
y (:y selrect)
|
y (:y selrect)
|
||||||
width (:width selrect)
|
width (:width selrect)
|
||||||
height (:height selrect )
|
height (:height selrect)]
|
||||||
fill (first (:fills object))]
|
(doseq [fill (reverse (:fills object))]
|
||||||
(js/console.log "fill" fill)
|
(do
|
||||||
(.uniform4fv gl (.getUniformLocation gl (.get programs "default") "u_color") (parse-color (:fill-color fill) (:fill-opacity fill)))
|
(.uniform4fv gl (.getUniformLocation gl (.get programs "default") "u_color") (parse-color (:fill-color fill) (:fill-opacity fill)))
|
||||||
(.uniform2f gl (.getUniformLocation gl (.get programs "default") "u_size") width height)
|
(.uniform2f gl (.getUniformLocation gl (.get programs "default") "u_size") width height)
|
||||||
(.uniform2f gl (.getUniformLocation gl (.get programs "default") "u_position") x y)
|
(.uniform2f gl (.getUniformLocation gl (.get programs "default") "u_position") x y)
|
||||||
(.drawArrays gl (.-TRIANGLE_STRIP gl) 0 4))))
|
(.drawArrays gl (.-TRIANGLE_STRIP gl) 0 4))))))
|
||||||
|
|
||||||
(mf/defc canvas
|
(mf/defc canvas
|
||||||
"A canvas element with a WebGL context."
|
"A canvas element with a WebGL context."
|
||||||
@ -108,3 +110,6 @@
|
|||||||
[:canvas {:class (stl/css :canvas)
|
[:canvas {:class (stl/css :canvas)
|
||||||
:ref canvas-ref}]))
|
:ref canvas-ref}]))
|
||||||
|
|
||||||
|
;; TODO
|
||||||
|
;; - blend modes
|
||||||
|
;; - strokes
|
||||||
Loading…
x
Reference in New Issue
Block a user