Hi! I'm trying to mask graphics with other graphics
The code is basically this:
(defn draw [state]
(q/background 255)
(let [mask (q/create-graphics (q/width) (q/height) :p3d)
drawing (q/create-graphics (q/width) (q/height) :p3d)]
(q/with-graphics mask
(q/background 255))
(q/with-graphics drawing
(q/no-stroke)
(q/fill 200)
(q/with-translation [(* 0.5 (q/width)) (* 0.5 (q/height))]
(q/rect 0 0 100 100)))
(q/mask-image drawing mask)
(q/image drawing 0 0)))
Since I'm just a mask and fill it white I would have expected whatever I draw on the second graphics to be fully visible, but it's not
Interesting stuff. I've never used a lot of these functions. As I'm sitting here trying to understand them, this is what I wrote. Does it make anything clear? I feel like it makes sense. (defn draw [state] (let [mask (q/create-graphics 300 300) drawing (q/create-graphics 300 300)] (q/with-graphics mask (q/triangle 50 200 150 50 150 200)) (q/with-graphics drawing (q/background 0) (q/no-stroke) (q/fill 255 0 0) (q/with-translation [100 100] (q/rect 0 0 100 150))) (q/image mask 0 0) (q/image drawing 300 0) (q/mask-image drawing mask) (q/image drawing 600 0)))
:size [900 300]
I have a canvas containing only what I draw with the very first q/background
. Why? What am I missing? I tried different renderers because I read the docstring of q/mask-image
as this being a possible issue but that didn't change anything