We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it possible? Looking at the source code of Processing, it can't be done. In the end I need a GraphicsContext
from the PGraphicsFX2D
. I know that PGraphicsFX2D
has a method getNative()
, which returns the context, but the graphics is not visible in PSurfaceFX
.
Answers
If you show your attempt, then efforts will be focus on getting your attempt working. Right now, efforts are funneled to figure out what you are attempting in the first place.
Kf
@kfrajer I was attempting to implement
clip()
in FX2D for my sketch. Unfortunately, the renderer doesn't support clipping, so I deciced to implement a somewhat flawed but functioning solution on my own.I have already figured out that I can get the
GraphicsContext
from aCanvas
object usinggetGraphicsContext2D()
, and this is my solution:And that's how I've implemented
clip()
andnoClip()
:This is not a great solution because
GraphicsContext#save
saves all the common properties like the fill and stroke color, which will reset my settings to the ones when I callclip()
. In my sketch this won't be that big of a deal, but for implementing this solution to Processing itself it needs to be improved.Anyways, issue fixed.
EDIT: That tag in the
@Override
tags is not my fault, it's the syntax highlighterEDIT #2: Now I just understood that this solution is unusable for animation, 'cause it makes the sketch go nuts.
EDIT #3!: I just removed a
clip()
call and it works just fine now. Dunno why it did this weird stuff thoThxs for sharing you solution. You can describe your clip() version in github as a feature request and they could added into their to do things. You can also exchange ideas here in the forum (as you have done) to see if there are any other way to implement it, or maybe find an alternative approach. Regarding the
@override
tag, it is a known bug in the forum. You can add a space to solve the issue like this:@ Override
Kf