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

Re : Exporting to dxf or pdf

$
0
0
I actually spent allot of time on the link you listed.

I know Import processing goes at the beginning of the script.

  1. import processing. pdf.*;
  2. ArrayList history = new ArrayList();
  3. float distthresh = 60;

  4. void setup(){
  5.   size(900,600);
  6.   background(255);
  7.   stroke(0,50);
  8.   smooth();
  9. }


  10. void draw(){
  11.   
  12. }

  13. void mouseDragged(){

  14.   PVector d = new PVector(mouseX,mouseY,0);
  15.   history.add(0,d);
  16.   
  17.   for (int p=0; p<history.size(); p++){
  18.     PVector v = (PVector) history.get(p);
  19.     float joinchance = p/history.size() + d.dist(v)/distthresh;
  20.     if (joinchance < random(0.4))  line(d.x,d.y,v.x,v.y);
  21.   }
  22. }

  23. void keyPressed(){
  24.   if (key == ' ') {
  25.     background(255);
  26.     history.clear();
  27.   }
  28. }
Then I get errors when I type in the rest of the code below when I run the file. It does not export.
void setup() {
  size(400, 400, PDF, "filename.pdf");
}

void draw() {
  // Draw something good here
  line(0, 0, width/2, height);

  // Exit the program 
  println("Finished.");
  exit();
}

Viewing all articles
Browse latest Browse all 1768

Trending Articles