Advertisement
xeromino

tri

May 7th, 2015
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. PImage img;
  2.  
  3. void setup() {
  4.   img = loadImage("https://s-media-cache-ak0.pinimg.com/736x/d1/cd/39/d1cd392fe6a250f8cc419f0d3eb43acb.jpg");
  5.   size(img.width, img.height);
  6.   img.filter(POSTERIZE, 10);
  7.   background(20);
  8.   noStroke();
  9.   //image(img,0,0);
  10. }
  11.  
  12. void draw() {
  13.   for (int i=0; i<50; i++) {
  14.     paintStroke();
  15.   }
  16. }
  17.  
  18. void paintStroke() {
  19.   int tx = (int) random(width);
  20.   int ty = (int) random(height);
  21.   translate(tx, ty);
  22.   color col = img.get(tx, ty);
  23.   fill(col, 200);
  24.   pushMatrix();
  25.   rotate(random(TWO_PI));
  26.   beginShape();
  27.   float angle=0;
  28.   float d = random(5, 20);
  29.   for (int i=0; i<3; i++) {
  30.     float x = cos(angle)*d;
  31.     float y = sin(angle)*d;
  32.     vertex(x, y);
  33.     angle+=TWO_PI/3;
  34.   }
  35.   endShape(CLOSE);
  36.   popMatrix();
  37. }
  38.  
  39. void keyPressed() {
  40.   save(random(1234)+".jpg");
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement