How to save high quality video when not clearing the background

edited January 2018 in Library Questions

Hey guys!

I'm trying to export a high quality video from a little animation I've made but so far I can't get it to work correctly. The animation I need to export is created by a line moving with the background not cleared and this what is causing a problem. In order to have the right high quality I'm exporting a pdf with multiple pages but these have the background cleared so I can not use it for the final video. Exporting every frame as a png loses most of the quality so the final video is not good enough. Is there a way to save every frame, with the background not cleared, as a pdf? Any help is very appreciated!

Thank you very much! :)

Here is the code I'm using so far.

import processing.pdf.*;
import processing.opengl.*;

PGraphicsPDF pdf;

float r = 0;
float theta = 0;

int freqX = 5;
int freqY = 15;
int phi = 111;


void setup(){
   size(displayWidth,displayHeight,OPENGL);
   smooth(8);
   background(255,255,255);
   pdf = (PGraphicsPDF)beginRecord(PDF, "Sketch.pdf");
   //beginRecord(PDF, "frame-####.pdf"); 
}

void draw(){ 
   translate (width/2, height/2);

   float x = r * sin(theta * freqX + radians(phi)) * cos(theta)*5;
   float y = sin(theta * freqY) * cos(theta);
   y *= 200;
   x *= 2;
   r += 0.1;
   theta += 0.001;

   stroke(0,0,0,30);
   strokeWeight(1);
   noFill();

   line(0, 0, x , y);

   pdf.nextPage();
}

void keyPressed() {
  if (key == 'q') {
    endRecord();
    exit();
  } 
}
Sign In or Register to comment.