Hi all, i’m a few weeks into learning coding/Processing but am struggling a bit with taking my processing creations and exporting them to SVG files. Below is a program that i’ve written up in Processing and i’d really like to be able to send it to my pen plotter to draw as its a small achievement for me. I’m not sure whether i need to just rewrite it all in a different format that will export or whether i can just adapt it with a few lines of code and then export. I’ve tried using beginRecord/endRecord and such but i’m never left with the full wave, usually just a single line. I’d really appreciate any help as its driving me a bit nuts!
float a = 0;
float aincrease = (PI/500);
float x = 0;
float z = 0;
void setup(){
size(800,350);
frameRate(200);
background(255);
}
void draw(){
float r = 100;
float y = r*-sin(a);
translate(0,height/2);
a = a + aincrease;
x = x + 0.2;
//x axis
line(0,0,width,0);
if(z < width){
line(z,0+2,z,0-2);
z = z + 50;
}
//wave
if(x < width){
fill(0);
point(x,y);
}
}
You may have only been saving the final frame; there is a comment about this in the library reference.
What you see on the sketch window is an accumulation of individual frames over time painted to the sketch window.
Reference:
Here is an example adapted from the reference above that will draw a sine wave in a single for() loop and then display it:
You get very different SVG file outputs (use a text editor to view) with a shape vs a line.
I don’t have access to a plotter and do not know how these will plot… please share results.
Hi there -
I came across this topic since I am trying to do the exact same thing in P5.JS, but struggling to get an SVG output. I’m curious if it is possible.
Does anyone have any ideas?
Thank you in advance.
I have no idea if this code exports something which could be used for pen plotting. The graphic may be seen by double clicking on the index.html file in the sketch folder.