Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int now;
- int rectsize = 1;
- int wd = 315;
- int ht = 315;
- // tem a ver com o tamanho do circulo. = 4 fica mais brilhante
- float res = 7;
- PImage a;
- PImage tex;
- PImage lookup;
- PImage redcloud;
- PImage greencloud;
- PImage bluecloud;
- PImage redbluecloud;
- PImage darkgreycloud;
- PImage greycloud;
- PImage redgreencloud;
- PImage b;
- PImage orig;
- float [] alookup = new float [wd*ht];
- float [] _x = new float [500];
- float [] _y = new float [500];
- PVector [] ka= new PVector [wd*ht];
- int [] x= new int [2];
- String cloudcolour = "blue";
- int _x1;
- int _ly;
- int _y1;
- void setup(){
- mouseX = wd;
- mouseY = ht; // antigo valor era zero
- fullScreen ();
- // relacionados com a intensidade da coloração
- float xm = wd;
- float ym = ht;
- for (int i = 0 ; i < wd*ht ; i++){
- _y1 = int (i / wd);
- _x1 = i - (_y1 * wd);
- float dis = dist (_x1, _y1, 0, 0); // aaahn, o cara fez quatro círculos que se mesclam.
- ka[i] = new PVector ( dis, _x1, _y1);
- }
- a = createImage(wd,ht,ARGB);
- redcloud = createImage(wd, ht, ARGB);
- greencloud= createImage(wd, ht, ARGB);
- bluecloud= createImage(wd, ht, ARGB);
- redbluecloud = createImage(wd, ht, ARGB);
- greycloud = createImage(wd, ht, ARGB);
- redgreencloud = createImage(wd, ht, ARGB);
- darkgreycloud =createImage(wd, ht, ARGB);
- now = 0;
- noStroke();
- lookup= createImage(wd, ht, ARGB);
- // muda a área de recolhimento de pixels na vertical
- for ( x[now] = 0 ; x[now] < wd ; x[now] += rectsize ) {
- now = 1 ; // lembrando que esse array tem 2 indices, o 0 e o 1
- //muda a área de recolhimento de pixels na horizontal
- for (x[now] = 0; x[now] < ht ; x[now] += rectsize ) {
- //responsável pelo mudança no alpha, que esmaece a cor no circulo.
- float z = distx2 ( x[now], x[now-1], wd/2, ht/2 ) * res;
- // teste sobre distribuição do pos.
- int _wd = wd;
- int pos = x[now] + _wd * x[now-1];
- if( z <= wd ) {
- int _x = x [now];
- int _y = x [now-1];
- /*float distx2 (float ax, float b, float c, float d){
- c = (c - ax);
- if (c < 0) c =- c;
- d = ( d - b);
- if ( d < 0) d =- d;
- ax = 0;
- b = 0;
- float retval = 0;
- int pos = int(c)+ wd * int(d);
- retval = ka[pos].x; // seria o campo que indica posição no eixo X?
- return retval;*/
- //muda a sequencia de cores apresentadas nos círculos
- float R = distx2 (_x, _y, 0, 0);
- float G = distx2 (_x, _y, wd-1, 0);
- float B = distx2 (_x, _y, wd, ht);
- // float A = distx2 (_x, _y, 0, ym-1);
- float alph = 315 - z ;
- lookup.pixels[pos]= color(z, z, z*2, 255-z); //int pos = x[now] + _wd * x[now-1];
- bluecloud.pixels[pos]= color(R, G, B, alph);
- redcloud.pixels[pos]= color(R, G, B, alph);
- greencloud.pixels[pos] = color(G, B, R, alph);
- redbluecloud.pixels[pos]= color(G, R, B, alph);
- greycloud.pixels[pos]= color(B, G, R, alph);
- darkgreycloud.pixels[pos]= color (B ,R ,G , alph);
- redgreencloud.pixels[pos]= color (z*2, z*2, z, 255-z );
- }
- alookup[pos] = z;
- }
- now = 0;
- }
- /*for (x[now ]= 0 ; x[now] < wd ; x[now] += rectsize ){
- now = 1;
- for (x[now]=0 ; x[now] < wd ; x[now] += rectsize ){
- float z = distx2 ( x[now], x[now-1], wd/2 ,ht/2 );
- fill(1,255-z);
- rect(x[now],x[now-1],rectsize,rectsize);
- }
- now=0;
- }
- */
- background(-1);
- b=get();
- imageMode(3);
- }
- void draw(){
- if(mousePressed) {
- if(cloudcolour =="blue" )image(bluecloud, mouseX,mouseY);
- if(cloudcolour =="red" )image(redcloud, mouseX,mouseY);
- if(cloudcolour =="green")image(greencloud,mouseX,mouseY);
- if(cloudcolour=="mauve")image(redbluecloud,mouseX,mouseY);
- if(cloudcolour=="redgreen")image(redgreencloud,mouseX,mouseY);
- if(cloudcolour=="grey")image(greycloud,mouseX,mouseY);
- if(cloudcolour=="darkgrey")image(darkgreycloud,mouseX,mouseY);
- }
- salve ();
- }
- void salve () {
- if (keyPressed) save ("cloud.png");
- }
- float distx2 (float ax, float b, float c, float d){
- c = (c - ax);
- if (c < 0) c =- c;
- d = ( d - b);
- if ( d < 0) d =- d;
- ax = 0;
- b = 0;
- float retval = 0;
- int _wd = wd;
- int pos = int(c)+ _wd * int(d);
- retval = ka[pos].x; // seria o campo que indica posição no eixo X?
- return retval;
- }
- void keyPressed(){
- if(key =='r' || key =='R')cloudcolour = "red";
- if(key=='g' || key== 'G')cloudcolour="green";
- if(key=='b' || key =='B')cloudcolour = "blue";
- if(key=='e') cloudcolour = "grey";
- if(key=='G')cloudcolour = "darkgrey";
- if(key=='y')cloudcolour = "redgreen"; //yellow
- if(key=='m')cloudcolour= "mauve"; //purple
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement