Export SVG problems

Hello there! I’m trying to export a frame from an animation from processing with .svg format, because i need that frame in a vector graphic format (because i’d like to print it), but so far i couldnt do it. Every time i try to save it, it only saves the svg as a blank white background.

Do any of you guys knows any sort of solution regarding this code?

import processing.svg.*;

boolean record;

PFont font;
PGraphics pg;

void setup() {
  font = createFont("RobotoMono-Regular.ttf", 600);
  size(800, 800, P2D);
  pg = createGraphics(800, 800, P2D);


void draw() {

 if (record) {
    beginRaw(SVG, "output.svg");

  // PGraphics 

  pg.translate(width/2, height/2-215);
  pg.textAlign(CENTER, CENTER);
  pg.text("z", 0, 0);

  int tilesX = 16;
  int tilesY = 16;

  int tileW = int(width/tilesX);
  int tileH = int(height/tilesY);

  for (int y = 0; y < tilesY; y++) {
    for (int x = 0; x < tilesX; x++) {

      // WARP
      int wave = int(sin(frameCount * 0.05 + ( x * y ) * 0.07) * 100);

      // SOURCE
      int sx = x*tileW + wave;
      int sy = y*tileH;
      int sw = tileW;
      int sh = tileH;

      int dx = x*tileW;
      int dy = y*tileH;
      int dw = tileW;
      int dh = tileH;
      copy(pg, sx, sy, sw, sh, dx, dy, dw, dh);

    if (record) {
    record = false;

// Hit 'r' to record a single frame
void keyPressed() {
  if (key == 'r') {
    record = true;
1 Like

did you try from

import processing.svg.*;

PGraphics svg = createGraphics(300, 300, SVG, "output.svg");

because you create a image on P2D, that would not show up anything in SVG

while with the normal save(outfile);
you could use


that not works with SVG lib??

other problem:

copy(pg, sx, sy, sw, sh, dx, dy, dw, dh);

is a pixel thing, does not work for SVG

try all without your pg.
ended at [r] with error

texture() is not available with this renderer.
vertex(x, y, u, v) is not available with this renderer.

so possibly font problems too

1 Like