Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Processing Pen Tool Simple

By: BrokenStylus on Sep 14th, 2013  |  syntax: None  |  size: 0.79 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Processing Draw Tool (black and white)
  2.  
  3. //COPYPASTA BELOW INTO PROCESSING WINDOW AND CLICK THE PLAY BUTTON
  4.  
  5. /*Instructions
  6. Wait a few seconds after hitting the play button
  7. Left click Black Pen
  8. Right click Eraser
  9. */
  10.  
  11. int paletteBlack = 0;
  12. int paletteWhite = 255;
  13. void setup() {
  14.   size(displayWidth, displayHeight);
  15.   smooth(4);
  16.   background(255);
  17.   ellipseMode(CENTER);
  18. }
  19.  
  20. void draw() {
  21.   if (mousePressed && (mouseButton == LEFT)) {
  22.     stroke(paletteBlack);
  23.     strokeWeight(10);
  24.     fill(paletteBlack);
  25.     line(mouseX, mouseY, pmouseX, pmouseY);
  26.   }
  27.  
  28.   else if (mousePressed && (mouseButton == RIGHT)) {
  29.     stroke(paletteWhite);
  30.     strokeWeight(20);
  31.     fill(paletteWhite);
  32.     line(mouseX, mouseY, pmouseX, pmouseY);
  33.   }
  34.   else {
  35.     noFill();
  36.     noStroke();
  37.   }
  38. }