Save transparent image from Geomerative

I have geomerative installed to modify an svg. I want to save an image with a transparent background whenever I left-click. However, using the code below, whenever I left click it only saves an image of the unmodified svg with a transparent background.

import geomerative.*;

RShape grp;
PGraphics img;

int first = 0;

void setup(){
  size(600, 600);
  
  RG.init(this);
  
  background(#2D4D83);
  
  img = createGraphics(width, height);
    
  grp = RG.loadShape("bot1.svg");
  grp = RG.centerIn(grp, g);
  
}

void draw(){
  img.beginDraw();
  img.translate(width/2, height/2);
  
  translate(width/2, height/2);
  
  float t = map(mouseX, 0, width, 0, 1);
  RShape[] splittedGroups = grp.splitPaths(t);
  
  RG.shape(splittedGroups[first]);
  grp.draw(img);
  img.endDraw();
}

void mousePressed(){
  first = (first + 1) % 2;
  img.save("image_" + millis() + ".png");
}

Not sure how I can make the draw command recognise the modified svg image.

Impossible to transform a RShape in PShape, so I found this alternative :

import geomerative.*;
RShape grp;
PGraphics img;
int first = 0;
PImage buf;
void setup() {
  size(600, 600);
  RG.init(this);
  background(#2D4D83);
  img = createGraphics(width, height);
  buf = createImage(width, height, RGB);
  grp = RG.loadShape("tiger.svg");
  grp = RG.centerIn(grp, g);
}
void draw() {
  img.beginDraw();
  img.translate(width/2, height/2);
  translate(width/2, height/2);
  float t = map(mouseX, 0, width, 0, 1);
  RShape[] splittedGroups = grp.splitPaths(t);
  RG.shape(splittedGroups[first]);
  grp.draw(img);
  img.endDraw();
  loadPixels();
  for (int i = 0; i < img.pixels.length; i++) {
    buf.pixels[i] = pixels[i];
  }
  updatePixels();
}
void mousePressed() {
  first = (first + 1) % 2;
  buf.save("image_" + millis() + ".png");
}

Thanks! This helps with save an image but not with saving a transparent image. Any thoughts on how to save a transparent image?

You might try commenting out the background line to see if that makes a difference.
Not sure if this is THE solution, but it is where I would start.
:nerd_face:

Doesn’t work sadly. It just saves an image with the default light grey background (and with animation frames overlaid as the background isn’t redrawn)

This is an interesting thread which may be of help:

Thanks but it doesn’t help either. As @matheplica pointed out it’s not possible to convert an RShape into a PShape (which the method you posted uses).