Facebook
From Fiery Goose, 2 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 78
  1. PImage photo;
  2.  
  3. void setup() {
  4.   size(1920, 1281);
  5.   photo = loadImage("czy-psy-sie-poca-min.jpg");
  6.  
  7.   cw4();
  8. }
  9.  
  10. void draw() {
  11.  // image(photo, 0, 0);
  12. }
  13.  
  14.  
  15. void cw1() {
  16.   photo.loadPixels();
  17.   for (int i = 0; i < photo.pixels.length; i++)
  18.   {
  19.  
  20.     color c = photo.pixels[i];
  21.    
  22.     photo.pixels[i] = color((red(c)+ green(c) +blue(c)) / 3);
  23.   }
  24.     photo.updatePixels();
  25. }
  26.  
  27. void cw2() {
  28.   photo.loadPixels();
  29.   for (int i = 0; i < photo.pixels.length; i++)
  30.   {
  31.  
  32.     color c = photo.pixels[i];
  33.     float a1 = 0.2;
  34.     float a2 = 0.3;
  35.     float a3 = 0.5;
  36.    
  37.     photo.pixels[i] = color(a1 * red(c) + a2* green(c) + a3* blue(c));
  38.   }
  39.     photo.updatePixels();
  40. }
  41.  
  42. void cw3() {
  43.   photo.loadPixels();
  44.   int a = 5;
  45.   for (int i = 0; i < photo.width; i+=a)
  46.   {
  47.     for (int j = 0; j < photo.height; j+=a)
  48.     {
  49.       color c = photo.get(i, j);
  50.       fill(c);
  51.       rect(i, j, a, a);
  52.     }
  53.    
  54.    
  55.   }
  56.     photo.updatePixels();
  57. }
  58.  
  59. void cw4() {
  60.   photo.loadPixels();
  61.   int a = 3;
  62.   for (int i = 0; i < photo.width; i+=a)
  63.   {
  64.     for (int j = 0; j < photo.height; j+=a)
  65.     {
  66.       color c = photo.get(i, j);
  67.       fill(c);
  68.      
  69.       int z = int(random(3));
  70.      
  71.       if (z == 0)
  72.       {
  73.         rect(i, j, a, a);
  74.       } else if (z == 1)
  75.       {
  76.         ellipse(i, j, a, a);
  77.       } else if (z == 2)
  78.       {
  79.         circle(i, j, a);
  80. //        stroke(c);
  81. //        line(i, j, a, a);
  82.       }
  83.     }  
  84.   }
  85.     photo.updatePixels();
  86. }