quil

heyarne 2020-04-13T10:41:55.001100Z

Hi! I'm trying to mask graphics with other graphics

heyarne 2020-04-13T10:43:04.001700Z

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)))

heyarne 2020-04-13T10:44:00.002600Z

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

2020-04-16T23:21:54.006700Z

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)))

2020-04-16T23:23:09.006900Z

2020-04-16T23:30:35.007300Z

:size [900 300]

heyarne 2020-04-13T10:45:34.004Z

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