Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masking graphics with other graphics #329

Open
heyarne opened this issue Apr 13, 2020 · 1 comment
Open

Masking graphics with other graphics #329

heyarne opened this issue Apr 13, 2020 · 1 comment

Comments

@heyarne
Copy link
Contributor

heyarne commented Apr 13, 2020

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 builing a mask completely white mask I would have expected whatever I draw on the second graphics to be fully visible, but it's not. The result is 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.

@Jeiwan
Copy link

Jeiwan commented Sep 13, 2021

This is still an issue. A workaround is to use .mask method:

(.mask drawing mask)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants