I learned to use snapshot
to make an Image
object out of a node. Having multiple Group
s that hold various strokes, I'm now trying to create a single Image with strokes from both groups. For this purpose I'm using the following code:
Group strokes1;
Group strokes2;
WriteableImage im = null;
SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.TRANSPARENT);
params.setViewport(new Rectangle2D(0, 0, 400, 400));
im = strokes1.snapshot(params, im);
im = strokes2.snapshot(params, im);
The documentation for the snapshot
function says that
"If the image is non-null, the node will be rendered into the existing image."
However, the resulting Image im
only contains strokes from strokes2
. What am I doing wrong?