SHARE
TWEET

cloudMaker_org

a guest Mar 22nd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. int now;
  3. int rectsize = 1;
  4. int wd = 315;
  5. int ht = 315;
  6. // tem a ver com o tamanho do circulo. = 4 fica mais brilhante
  7. float res = 6;
  8.  
  9. PImage a;
  10. PImage tex;
  11. PImage lookup;
  12. PImage redcloud;
  13. PImage greencloud;
  14. PImage bluecloud;
  15. PImage redbluecloud;
  16. PImage darkgreycloud;
  17. PImage greycloud;
  18. PImage redgreencloud;
  19. PImage b;
  20. PImage orig;
  21.  
  22. float [] alookup = new float [wd*ht];
  23. float [] _x = new float [500];
  24. float [] _y = new float [500];
  25. PVector [] ka= new PVector [wd*ht];
  26.  
  27. int [] x= new int [2];
  28. String cloudcolour = "blue";
  29.  
  30. int _x1;
  31. int _ly;
  32. int _y1;
  33.  
  34. void setup(){
  35.   mouseX = wd;
  36.   mouseY = ht; // antigo valor era zero
  37.   fullScreen ();
  38.  
  39.   // relacionados com a intensidade da coloração
  40.   float xm = wd;
  41.   float ym = ht;
  42.  
  43.   for (int i = 0 ; i < wd*ht ; i++){
  44.     _y1 = int (i / wd);
  45.     _x1  = i - (_y1 * wd);
  46.     float dis = dist (_x1, _y1, 0, 0); // aaahn, o cara fez quatro círculos que se mesclam.
  47.     ka[i] = new PVector ( dis, _x1, _y1);
  48.   }
  49.   a = createImage(wd,ht,ARGB);
  50.   redcloud = createImage(wd, ht, ARGB);
  51.   greencloud= createImage(wd, ht, ARGB);
  52.   bluecloud= createImage(wd, ht, ARGB);
  53.   redbluecloud = createImage(wd, ht, ARGB);
  54.   greycloud = createImage(wd, ht, ARGB);
  55.   redgreencloud = createImage(wd, ht, ARGB);
  56.   darkgreycloud =createImage(wd, ht, ARGB);
  57.   now = 0;
  58.   noStroke();
  59.   lookup= createImage(wd, ht, ARGB);
  60.  
  61.   // muda a área de recolhimento de pixels na vertical
  62.   for ( x[now] = 0 ; x[now] < wd ; x[now] += rectsize ) {
  63.     now = 1 ; // lembrando que esse array tem 2 indices, o 0 e o 1
  64.    
  65.     //muda a área de recolhimento de pixels na horizontal
  66.     for (x[now] = 0; x[now] < ht ; x[now] += rectsize ) {
  67.      
  68.       //responsável pelo mudança no alpha, que esmaece a cor no circulo.
  69.       float z = distx2 ( x[now], x[now-1], wd/2, ht/2 ) * res;
  70.      
  71.       // teste sobre distribuição do pos.
  72.       int _wd = wd;
  73.      
  74.       int pos = x[now] + _wd * x[now-1]; // qual o valor contido no primeiro indice?
  75.                                          // pq a expressão de pos está aqui, e não no final?
  76.       if( z <= wd ) {
  77.  
  78.         float k = distx2 ( x[now] , x[now-1], xm, ym);
  79.         int _x = x [now];
  80.         int _y = x [now-1];
  81.        
  82.         /*float distx2 (float ax, float b, float c, float d){
  83.   c = (c - ax);
  84.   if (c < 0) c =- c;
  85.   d = ( d - b);
  86.   if ( d < 0) d =- d;
  87.  
  88.   ax = 0;
  89.   b = 0;
  90.  
  91.   float retval = 0;
  92.   int pos = int(c)+ wd * int(d);
  93.  
  94.   retval = ka[pos].x; // seria o campo que indica posição no eixo X?
  95.   return retval;*/
  96.        
  97.         //muda a sequencia de cores apresentadas nos círculos
  98.         float R = distx2 (_x, _y, 0, 0); // mudar aqui muda a coloração do circulo
  99.         float G = distx2 (_x, _y, wd-1, 0);
  100.         float B = distx2 (_x, _y, wd, ht);  
  101.        // float A = distx2 (_x, _y, 0, ym-1);
  102.  
  103.         float alph = 255 - z ;
  104.        
  105.         lookup.pixels[pos]= color(z, z, z*2, 255-z);
  106.  
  107.         bluecloud.pixels[pos]= color(R, G, B, alph);
  108.  
  109.         redcloud.pixels[pos]= color(R, B, G, alph);
  110.  
  111.         greencloud.pixels[pos] = color(G, B, R, alph);
  112.  
  113.         redbluecloud.pixels[pos]= color(G, R, B, alph);
  114.  
  115.         greycloud.pixels[pos]= color(B, G, R, alph);
  116.  
  117.         darkgreycloud.pixels[pos]= color (B ,R ,G , alph);
  118.        
  119.         redgreencloud.pixels[pos]= color (z*2, z*2, z, 255-z );
  120.       }
  121.      
  122.       alookup[pos] = z;
  123.     }
  124.    
  125.     now = 0;
  126.   }
  127.  
  128.   /*for (x[now ]= 0 ; x[now] < wd ; x[now] += rectsize ){
  129.     now = 1;
  130.    
  131.     for (x[now]=0 ; x[now] < wd ; x[now] += rectsize ){
  132.      
  133.       float z = distx2 ( x[now], x[now-1], wd/2 ,ht/2 );
  134.       fill(1,255-z);
  135.       rect(x[now],x[now-1],rectsize,rectsize);
  136.  
  137.     }
  138.     now=0;
  139.   }
  140. */
  141.   background(-1);
  142.   b=get();
  143.   imageMode(3);
  144. }
  145.  
  146. void draw(){
  147.  
  148.   if(mousePressed) {
  149.     if(cloudcolour =="blue" )image(bluecloud, mouseX,mouseY);
  150.     if(cloudcolour =="red"  )image(redcloud,  mouseX,mouseY);
  151.     if(cloudcolour =="green")image(greencloud,mouseX,mouseY);
  152.     if(cloudcolour=="mauve")image(redbluecloud,mouseX,mouseY);
  153.     if(cloudcolour=="redgreen")image(redgreencloud,mouseX,mouseY);
  154.     if(cloudcolour=="grey")image(greycloud,mouseX,mouseY);
  155.     if(cloudcolour=="darkgrey")image(darkgreycloud,mouseX,mouseY);
  156.  
  157.   }
  158. }
  159.  
  160. float distx2 (float ax, float b, float c, float d){
  161.   c = (c - ax);
  162.   if (c < 0) c =- c;
  163.   d = ( d - b);
  164.   if ( d < 0) d =- d;
  165.  
  166.   ax = 0;
  167.   b = 0;
  168.  
  169.   float retval = 0;
  170.   int pos = int(c)+ wd * int(d);
  171.  
  172.   retval = ka[pos].x; // seria o campo que indica posição no eixo X?
  173.   return retval;
  174. }
  175.  
  176. void keyPressed(){
  177.   if(key =='r' || key =='R')cloudcolour = "red";
  178.   if(key=='g' || key== 'G')cloudcolour="green";
  179.   if(key=='b' || key =='B')cloudcolour = "blue";
  180.   if(key=='e') cloudcolour = "grey";
  181.   if(key=='G')cloudcolour = "darkgrey";
  182.   if(key=='y')cloudcolour = "redgreen"; //yellow
  183.   if(key=='m')cloudcolour= "mauve"; //purple
  184.  
  185. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top