Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : pfd export a specific area / box

$
0
0
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.


  1. import controlP5.*;
  2. import processing.pdf.*;

  3. // using controlP5 version 2.0.4 with processing 2.0b7
  4. ControlP5 cp5; 

  5. boolean record;

  6. void setup() {
  7.   size(800,600);
  8.   
  9.   cp5 = new ControlP5( this );
  10.   
  11.   Bang b = cp5.addBang( "save" )
  12.               .setPosition( 20 , 20 )
  13.               .setSize( 100 , 100 )
  14.               ;
  15.               
  16.   b.getCaptionLabel()
  17.    .align( CENTER , CENTER )
  18.    ;
  19.   
  20. }

  21. void draw() {
  22.   background( 230 );
  23.   
  24.   pushMatrix();
  25.   if( record ) {
  26.     beginRecord( PDF , "grid-" + frameCount + ".pdf" );
  27.   }
  28.   
  29.   fill( 0 );
  30.   translate( 200 , 50 );
  31.   
  32.   for( int i = 0 ; i < 250 ; i++ ) {
  33.     float f = sin( ( frameCount + i ) * 0.01 );
  34.     pushMatrix();
  35.     translate( ( i * 50 ) % 500 , ( i / 10 ) * 20 );
  36.     rotate(f);
  37.     rect( 0 , 0 , 50 , 2 );
  38.     popMatrix();
  39.   }
  40.   if( record ) {
  41.     record = false;
  42.     endRecord();
  43.   }
  44.   popMatrix();
  45.   
  46. }

  47. void save() {
  48.   record = true;
  49. }



Viewing all articles
Browse latest Browse all 1768

Trending Articles