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

Is there a way to use erase() within SVG graphics? #197

Open
twonyn opened this issue Oct 27, 2021 · 1 comment
Open

Is there a way to use erase() within SVG graphics? #197

twonyn opened this issue Oct 27, 2021 · 1 comment

Comments

@twonyn
Copy link

twonyn commented Oct 27, 2021

Im to create a pattern with transparency within p5.js but using rasterised shapes slowed down the browser too much so I opted for p5.js-svg. Sadly I cannot figure out how to create a circular cutout.

Within standard p5 I would do this:

symbol = createGraphics(100,100);  
symbol.fill('blue');  
symbol.rect(0,0,100,100);  
symbol.erase();  
symbol.ellipse(50,50,80,80);  

and then paste that Graphic over the canvas.

But using an SVG Graphics, erase() only makes the area white and not transparent. I also tried importing an svg and changing the fill attribute but can't seem to make that happen within a Graphics container.

I tried some things out within the sketch below but none of them work properly.
https://editor.p5js.org/lichtelucas/sketches/LYju8KThw

Thanks in advance!

@zenozeng
Copy link
Owner

zenozeng commented Nov 11, 2021

@twonyn Unfortunately, I have not thought of a good way to achieve this function. It’s white because svgcanvas‘s current implement clearRect by adding a rect element, see also:
https://github.com/zenozeng/svgcanvas/blob/main/context.js#L839

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

No branches or pull requests

2 participants