Hi everyone!
I am trying to create a little drawing tool with processing. The final drawing should be exportable as a .svg file – so i thought this to be pretty easy… but actually it isnt… I put the background function into setup – to be able to draw – the safed svg file unfortunately only contains a single frame – and not the whole drawing. What am I missing – how could I achieve that! I would be thankful for any kind of help!
The code you posted looks like the single frame example from the SVG library reference with only very slight changes. The conditional at the top of draw() calls beginRecord(…) if “record” is true and the one at the bottom calls endRecord() and also sets “record” to false if it is currently true so the recording always starts and ends in the same frame.
Another boolean can be used to keep track of the current recording state and then the mouseClicked code can be modified to toggle the “recording” variable and used along with the new boolean to start recording if not currently recording or end recording if currently recording.
//...
void draw() {
if (record && !recording) {
// every frame if record is true
// but recording is not
// start recording and
// set recording to true
recording = true;
}
//...
if (!record && recording) {
// every frame if record is false
// and recording is true
// stop recording and
// set recording to false
recording = false;
}
}
void mousePressed() {
// set record to the opposite of what it
// was when the mouse was clicked
record = !record;
}