micycle1 / PGS

Processing Geometry Suite
https://micycle1.github.io/PGS/
167 stars 13 forks source link

`PShape.draw(PGraphics)` not working with shapes created by PGS #61

Closed thomassidor closed 2 years ago

thomassidor commented 2 years ago

Hi

Lovely library! Seems to work great when using it the default Processing way in draw().

However in my setup I maintan a stage where I can manage all the PShapes in the scene and draw them with their shape.draw(PGraphics) method (I'm passing the PApplet.g PGraphics to it).

This works great when I create shapes with createShape(), but when using methods from PGS I can't get the shapes to show at all.

I suspect - although it's really just a guess - it's since PGS creates new shapes with new PShape() and not createShape() - the latter sets the internal protected PGraphics g in the PShape - the constructor of PShape does not.

Or perhaps I'm way off.

Any thoughts on how I could investigate this further - or perhaps even a way to overcome it?

All the best, Thomas

micycle1 commented 2 years ago

Could you provide a small code example for me to play around with?

thomassidor commented 2 years ago

Hi Michael

Thanks for the quick reply!

Preparing an example for you I actually narrowed it down to something else than I thought!

I was using you hatching example (https://github.com/micycle1/PGS/blob/master/examples/dysonHatching/dysonHatching.pde) to hatch some random polygons and that weren't working.

The example you made runs fine - but I noticed that it uses FX2Dand not P2Dthat I use in my sketch.

Changing to P2Din your example gets me the same result as in my sketch - the hatching not showing up (and the sketch crashing when enabeling cell outlines).

Going over to 'FX2D' in my sketch fixes it! Great :)

Thanks a lot for the help (aka. forcing me to actually eliminate variables and not stare myself blind on what I assumed)!

Note to anyone reading this using ControlP5: ControlP5 crashes when using FX2Dunless you use the fix mentioned here: https://github.com/sojamo/controlp5/issues/36

micycle1 commented 2 years ago

Good to hear using FX2D fixes it.

I did look into the problems with shapes and P2D before -- I can't remember the exact details now -- but it is indeed due to circumventing createShape().

EDIT (from #39):

In 1.2.0, output PShapes are now always created with a shape family of PATH (rather than GEOMETRY) to maximise compatibility with the P2D renderer.