SVG Export in one file

Hello hello everyone, I used to export my svg with processing, but this time I can’t export a single svg with all the designs. Let me explain. Either it exports the first drawing, or it exports a file for each Frame. I would like it to export a single svg file with all the designs.

Thanks in advance for your help or advice :slight_smile:

import processing.svg.*;



float a, b, a1, b1, c, d, c1, d1;

float x; 

int y = 15;

/* 
Enregistrement du temps 
*/

int savedTime; 
int totalTime = 500;



void setup() {
  
  size(1280, 800);
  

  background(255);
  frameRate(1);
  
  savedTime = millis();
  


  a = random(x);
  b = random(x);
  a1 = random(x);
  b1 = random(x);
  


    
}

void draw() {
   

 

  
  
  x = width/y;
  

   // Calculate how much time has passed
  int passedTime = millis() - savedTime;
  



 
  


  // Has five seconds passed?

  for (int i = 1; i < (x*y); i = i+1) {


    
    if (passedTime > i*totalTime) {  
      
      translate(x, 0);
      
      
      
    }
  }

  for (int i = y; i < (x*y); i = i+y) {

    if (passedTime > i*totalTime) {  
      translate(-(x*y), x);
    }
  }



  if (passedTime > ((height/x)*y)*totalTime) {    
    
   
    
    noLoop();
   
    
  }
  

  



  // Get the end point

  c = random(x);
  d = random(x);
  c1 = random(x);
  d1 = random(x);

  
  strokeWeight(1);
  // Draw the line
  line(a, b, a1, b1);
  line(a, b, c, d);
  line(c, d, c1, d1);
  line(a1, b1, c1, d1);

  strokeWeight(8);
  point(a, b);
  point(a1, b1);
  point(c, d);
  point(c1, d1);



  // Set the end point as the new start point for the next loop
  
  a = c;
  b = d;
  a1 = c1;
  b1 = d1;
  


  
  println(frameCount);
  
  
}

Hi @Dimdimtri,

I suppose that when you call the noLoop() function, you want your program to stop and save your SVG file.

Use beginRecord() and endRecord() functions to save your svg :

void setup() {
  // Begin the record of the SVG
  beginRecord(SVG, "file.svg");
}

void draw() {
  // You draw here...

  // When you finished to draw
  if (passedTime > ((height/x)*y)*totalTime) {    
    noLoop();
    endRecord(); // End the SVG drawing
  }
}

Thank you for your answer, I also thought about doing it like that but I don’t know why he gives me a blank page. :grimacing:

If the position changes and I put in void draw … it only gives me a random drawing.