Advertisement
Guest User

cloudMaker_reorgColor

a guest
Mar 23rd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  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 = 7;
  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];
  75.  
  76. if( z <= wd ) {
  77.  
  78. int _x = x [now];
  79. int _y = x [now-1];
  80.  
  81. /*float distx2 (float ax, float b, float c, float d){
  82. c = (c - ax);
  83. if (c < 0) c =- c;
  84. d = ( d - b);
  85. if ( d < 0) d =- d;
  86.  
  87. ax = 0;
  88. b = 0;
  89.  
  90. float retval = 0;
  91. int pos = int(c)+ wd * int(d);
  92.  
  93. retval = ka[pos].x; // seria o campo que indica posição no eixo X?
  94. return retval;*/
  95.  
  96. //muda a sequencia de cores apresentadas nos círculos
  97. float R = distx2 (_x, _y, 0, 0);
  98. float G = distx2 (_x, _y, wd-1, 0);
  99. float B = distx2 (_x, _y, wd, ht);
  100. // float A = distx2 (_x, _y, 0, ym-1);
  101.  
  102. float alph = 315 - z ;
  103.  
  104. lookup.pixels[pos]= color(z, z, z*2, 255-z); //int pos = x[now] + _wd * x[now-1];
  105.  
  106. bluecloud.pixels[pos]= color(R, G, B, alph);
  107.  
  108. redcloud.pixels[pos]= color(R, G, B, alph);
  109.  
  110. greencloud.pixels[pos] = color(G, B, R, alph);
  111.  
  112. redbluecloud.pixels[pos]= color(G, R, B, alph);
  113.  
  114. greycloud.pixels[pos]= color(B, G, R, alph);
  115.  
  116. darkgreycloud.pixels[pos]= color (B ,R ,G , alph);
  117.  
  118. redgreencloud.pixels[pos]= color (z*2, z*2, z, 255-z );
  119. }
  120.  
  121. alookup[pos] = z;
  122. }
  123.  
  124. now = 0;
  125. }
  126.  
  127. /*for (x[now ]= 0 ; x[now] < wd ; x[now] += rectsize ){
  128. now = 1;
  129.  
  130. for (x[now]=0 ; x[now] < wd ; x[now] += rectsize ){
  131.  
  132. float z = distx2 ( x[now], x[now-1], wd/2 ,ht/2 );
  133. fill(1,255-z);
  134. rect(x[now],x[now-1],rectsize,rectsize);
  135.  
  136. }
  137. now=0;
  138. }
  139. */
  140. background(-1);
  141. b=get();
  142. imageMode(3);
  143. }
  144.  
  145. void draw(){
  146.  
  147. if(mousePressed) {
  148. if(cloudcolour =="blue" )image(bluecloud, mouseX,mouseY);
  149. if(cloudcolour =="red" )image(redcloud, mouseX,mouseY);
  150. if(cloudcolour =="green")image(greencloud,mouseX,mouseY);
  151. if(cloudcolour=="mauve")image(redbluecloud,mouseX,mouseY);
  152. if(cloudcolour=="redgreen")image(redgreencloud,mouseX,mouseY);
  153. if(cloudcolour=="grey")image(greycloud,mouseX,mouseY);
  154. if(cloudcolour=="darkgrey")image(darkgreycloud,mouseX,mouseY);
  155.  
  156. }
  157. salve ();
  158. }
  159.  
  160. void salve () {
  161. if (keyPressed) save ("cloud.png");
  162. }
  163.  
  164. float distx2 (float ax, float b, float c, float d){
  165. c = (c - ax);
  166. if (c < 0) c =- c;
  167. d = ( d - b);
  168. if ( d < 0) d =- d;
  169.  
  170. ax = 0;
  171. b = 0;
  172.  
  173. float retval = 0;
  174. int _wd = wd;
  175. int pos = int(c)+ _wd * int(d);
  176.  
  177. retval = ka[pos].x; // seria o campo que indica posição no eixo X?
  178. return retval;
  179. }
  180.  
  181. void keyPressed(){
  182. if(key =='r' || key =='R')cloudcolour = "red";
  183. if(key=='g' || key== 'G')cloudcolour="green";
  184. if(key=='b' || key =='B')cloudcolour = "blue";
  185. if(key=='e') cloudcolour = "grey";
  186. if(key=='G')cloudcolour = "darkgrey";
  187. if(key=='y')cloudcolour = "redgreen"; //yellow
  188. if(key=='m')cloudcolour= "mauve"; //purple
  189.  
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement