Trouble creating PDF

edited April 2015 in Library Questions

when i run the code the PDF i am left with is just a blank white PDF. i cant find any issues with it so i was hoping you guys could help a struggler out

heres my code:

 //this code is heavily based off the library example code
//for the cell noise library

// Importing the library.
import CellNoise.*;
import processing.pdf.*;

CellNoise cn;


CellDataStruct cd;
double[] at = {
  200, 1000
};
double t = 0;
PImage im;
int x, y, i;

//THESE 2 FLOATS ARE THE KEY TO THE CHANGING DESIGN. DECLARING THE FLOAT INDICATES THAT EVERY LITTLE
//DECIMAL IN BETWEEN MAY BE USED. THIS TOOK WAY TOO LONG TO FIGURE OUT.
float yPos = random(0.001,0.016);
float xPos = random(0.0008,0.02);
float ab = random(18, 20);
float ba = random(450, 700);

void setup() {


  size(800, 1000);
  noLoop();
  beginRecord(PDF, "filename.pdf");
  //size(4961,7016);
  cn = new CellNoise(this);
  cd = new CellDataStruct(this, 2, at, cn.EUCLIDEAN);



}

void draw() {
  loadPixels();


  //this affects the progressive "noisiness" of the image. key in changing the outcome of
  //both the more solid and more noisey design.
  t = 0;
  for (x = 0; x < width; x++) {
    at[0] = xPos * ( x + ab);
    for (y = 0; y < height; y++) {
      at[1] = yPos * ( y + ba );


      cd.at = at;

      cn.noise(cd);

//NOISEY NOISE

      at[0] = 0.01*cd.F[0] * (x + 20);
      at[1] = 0.01*cd.F[0] * (y + 700);
      cd.at = at;
      cn.noise(cd);

/**
      the code i have commented out here looks just too pixelated
      with no smoothe transitions especially when using random variables
      therefore i have replaced it with code used to create a block colour texture
      seen in the MANHATTAN style of noise as opposed to the EUCLIDEAN
      using the best of the two styles.
*/
      //pixels[x + y*width] = color((float)(cd.F[0])*random(30,40), (float)(cd.F[0]+cd.F[1])*random(130,150), (float)(cd.F[0])*random(100,130));

       pixels[x + y*width] = color((cd.ID[0] % 255), (cd.ID[0] % 100), (cd.ID[0] % 100));
  }
  }

  updatePixels();

  endRecord();

}
Tagged:

Answers

  • PDF doesn't work well with pixel manipulations (it is more a vector library than a bitmap one). Try using save() instead.

Sign In or Register to comment.