GMU:Actors, Traces, Collectives/SS17/Zufall: Difference between revisions

From Medien Wiki
(Created page with " →‎* * Mouse Press. * * Saves one SVG of the contents of the display window * each time the mouse is pressed.: import processing.svg.*; boolean saveOneFrame = fal...")
 
No edit summary
Line 1: Line 1:
/**
<syntaxhighlight lang="javaScript">
* Mouse Press.
 
*  
 
/**
  * Saves one SVG of the contents of the display window  
  * Saves one SVG of the contents of the display window  
  * each time the mouse is pressed.
  * each time the mouse is pressed.
Line 38: Line 39:
   filenumber = filenumber +1;
   filenumber = filenumber +1;
}
}
</syntaxhighlight>

Revision as of 06:18, 10 June 2017

 


/**
 * Saves one SVG of the contents of the display window 
 * each time the mouse is pressed.
 */


import processing.svg.*;

boolean saveOneFrame = false;
int filenumber = 0;

void setup() {
  size(600, 600);
  frameRate(24);
}

void draw() {
  if(saveOneFrame == true) {
    beginRecord(PDF, "Muster_"+filenumber+".svg"); 
  }
  
  background(255);
  strokeWeight(20.0);
  for(int i = 0;i<30;i++){
    stroke(random(255),random(255),random(255),100);
   line(random(width),random(height),random(width),random(height));
  }
  if(saveOneFrame == true) {
    endRecord();
    saveOneFrame = false; 
  }
}

void mousePressed() {
  saveOneFrame = true; 
  filenumber = filenumber +1;
}