Trying to rec a frame of my animation to SVG file

I am new to coding and I am working with this code to create a unique poster design using lines. I cannot successfully record a frame to an SVG file so I can use a pen plotter. I am sure I have a couple things out of order but I am too unfamiliar to identify the issue. If anyone has any suggestions, please help!!

//import svg library
import processing.svg.*;
//set up record boolean
boolean record;
//setup function runs only once
float x = 400;

void setup() {
  size(600, 600);
  frameRate(5);
  //noLoop();
  background(255);
  smooth();
  noCursor();
}

void draw(){
  // check if recording
  if (record) {
    //begin recording and call the file frame-framenumber
    beginRecord(SVG, "frame-###.svg");
  }

  translate(mouseY, mouseX);
  x = x+1; 
  rotate(radians(x));
 
  line(300, 150, 300, 120-x); 
  stroke(26);
  
 
 //check if recording
  if(record){
    endRecord();
    record = false;
  }
}

//check for keypress
void keyPressed(){
  if (key == 'b'){
    record = true;
  }
}
1 Like

Hello and welcome to the forum @JakeCodeNewbie !

Please note, unformatted code is hard to read. :face_with_monocle:

Increase your chances for a faster response to your question. Please format your code. To learn how: https://discourse.processing.org/faq#format-your-code

For example, this:

import processing.svg.*;    // import svg library

boolean record;    // set up record boolean

float x = 400;    // setup function runs only once

Is easier to read, than this:

//import svg library
import processing.svg.*;
//set up record boolean
boolean record;
//setup function runs only once
float x = 400;

Thank you!
:slightly_smiling_face:

2 Likes