function myCustomShape(paintCallback) {
applyStroke() // default paint
paintCallback() // custom paint optionally passed by user
drawCustomShape()
}
but there seem to be no way to do this right now in vvvv. I cannot think of a way to specify my own SkiaPaint styles and then add user supplied styles (if any) from an input pin.
I originally raised it as a question here. Please refer it to get the full context.
I’m not a JavaScript pro, but it seems that, conceptually, you just want to hand a delegate (callback function) and call it back (invoke it).
Or to put it in simple words:
You want to cut a hole into a patch.
To cut a hole into a patch, you can use a Invoke [Delegate], and ask for the delegate to be handed over, exactly like in your textual example.
Or even better, if you want to be able to hand over stateful puzzle pieces, follow the recipe for stateful regions:
Thanks @gregsn, I haven’t looked into custom regions and delegates properly up until now.
My use case is a little different and I don’t want to involve custom region in the API exposed to the user. Here’s in vvvv terms what I wanted (contrived):
Right now a Rectangle node draws a white filled rectangle by default. I want to create a wrapper node so that it gives me pink filled rectangle by default and keeps the same input pins as the original Rectangle node. So that if the user wants to provide their own fill, or stroke, they can.
If you could come up with a patch that solves this, then I’d appreciate it if you could send it to me here.
Just to clarify:
Your question sounded like you’d want to build a callback function and hand it over. In textual code you’d then have a code block somewhere that actually builds the delegate that you’d hand over to myCustomShape. The equivalent to this code block is the region in vvvv.
Oh I thought it’d be easier to understand if I used code but seems like I confused people even more. This post rather describes in vvvv terms what I wanted to achieve.
Hi. This is close, but still not what I wanted to achieve. If I only pass SetAlpha, the pink rectangle changes to white, while I expected it to remain pink because I haven’t overriden the fill:
The first patch that I sent you is the best solution for your original question in the other thread.
You said you want to leverage the feature of the stackability of paints, where you can build your default and based on that a user can put something below.
I can see that you don’t like the fact that regions come into play, but I currently don’t see another way to get the same desired behavior.
The second patch switches over to the user provided paint and if not provided uses the default, which is not leveraging the stackability feature..
In an ideal world you’d be able to define the default paint systemwide, but that’s not possible. It’s defined by us. Maybe you could come up with your own PaintWrapper Class and define a default for that?
I am okay with Skia nodes provided by VVVV to keep the default for Paint they have right now, but what I want is to have different defaults for my own wrapper nodes.
My use-case is that I am treating Process Nodes as UI components and I want to have sane defaults for my components. For example I have this FocusRect which draws corners like a camera does when it is focusing on a subject:
Sorrily this appraoch doesn’t work, as the skia paints on the second and third input have unconnected inputs and as of now build complete new paints, based on the systemwide default paint.
Building a Combine node would involve to rework the paint itself, so that it collects all the changes with regard to the system default and apply those changes ontop of the first provided paint.
This isn’t planned as of now.
Yet another approach is to have several default paints and use them in your shapes when no paint is fed. You don’t get the stackability, but at least each shape shows up as you want it to appear by default.