Hi, since controlP5 is by default drawn after processing has finished its own drawing routine, the following example shows you how to save a pdf without controlP5 elements.
- import controlP5.*;
- import processing.pdf.*;
- // using controlP5 version 2.0.4 with processing 2.0b7
- ControlP5 cp5;
- boolean record;
- void setup() {
- size(800,600);
- cp5 = new ControlP5( this );
- Bang b = cp5.addBang( "save" )
- .setPosition( 20 , 20 )
- .setSize( 100 , 100 )
- ;
- b.getCaptionLabel()
- .align( CENTER , CENTER )
- ;
- }
- void draw() {
- background( 230 );
- pushMatrix();
- if( record ) {
- beginRecord( PDF , "grid-" + frameCount + ".pdf" );
- }
- fill( 0 );
- translate( 200 , 50 );
- for( int i = 0 ; i < 250 ; i++ ) {
- float f = sin( ( frameCount + i ) * 0.01 );
- pushMatrix();
- translate( ( i * 50 ) % 500 , ( i / 10 ) * 20 );
- rotate(f);
- rect( 0 , 0 , 50 , 2 );
- popMatrix();
- }
- if( record ) {
- record = false;
- endRecord();
- }
- popMatrix();
- }
- void save() {
- record = true;
- }