int ancho=400,alto=300; FloatMatriz actual=new FloatMatriz(ancho,alto); FloatMatriz anterior=new FloatMatriz(ancho,alto); float relacion_con_la_vecindad(float actual, FloatMatriz ante, boolean mouseClick){ float valor; //-------------------------------------------------------------------------------------------------------------------------------- // INICIO de codigo a modificar - INICIO de codigo a modificar - INICIO de codigo a modificar - INICIO de codigo a modificar - //-------------------------------------------------------------------------------------------------------------------------------- float prom=0; float desvio=0; for(int i=0;i<8;i++){ prom+=ante.puntoCardinal(i); } prom/=8.0; if(mouseClick){ if(actual < prom){ valor = max(ante.ne(),ante.so())-random(10,30); }else{ valor = min(ante.e(),ante.o())+random(10,30); } }else{ valor = prom+3; if(valor>255){valor=0;} } //-------------------------------------------------------------------------------------------------------------------------------- // FIN de codigo a modificar - FIN de codigo a modificar - FIN de codigo a modificar - FIN de codigo a modificar - //-------------------------------------------------------------------------------------------------------------------------------- return valor; } void setup(){ size(800,600); actual.iniciarAzar(0,255); noStroke(); //framerate(2); } void loop(){ float pasoAncho = width/ancho; float pasoAlto = height/alto; for(int i=0;i lim2){ float sube = linea(valor,lim2,lim3,0,255); float baja = 255-sube; c = color(sube,0,baja); }else if(valor > lim1){ float sube = linea(valor,lim1,lim2,0,255); float baja = 255-sube; c = color(0,baja,sube); }else{ float sube = linea(valor,lim0,lim1,0,255); float baja = 255-sube; c = color(baja,sube,0); } return c; } float linea(float x,float x1, float x2, float y1, float y2){ return (x-x1)/(x2-x1)*(y2-y1)+y1; } //------------------------------------------------------------------------------------------------------------------------------------ // MARCA: FloatMatriz - FloatMatriz - FloatMatriz - FloatMatriz - FloatMatriz - FloatMatriz - FloatMatriz - FloatMatriz - FloatMatriz //------------------------------------------------------------------------------------------------------------------------------------ class FloatMatriz{ int col; int fil; int longi; float[] datos; int px,py; FloatMatriz(){ } FloatMatriz(int columnas,int filas){ this.inicia(columnas,filas); } void inicia(int columnas,int filas){ col=columnas; fil=filas; longi=fil*col; datos=new float[longi]; px = 0; py = 0; } void write(int x,int y,float valor){ datos[posi(x,y)]=valor; } float read(int x,int y){ return datos[posi(x,y)]; } void string(int desdeX,int desdeY, int hastaX, int hastaY){ println("Columnas="+col+" Filas="+fil); for(int j=desdeY;j<=hastaY;j++){ for(int i=desdeX;i<=hastaX;i++){ print(this.read(i,j)+" / "); } println(""); } } void string(){ println("Columnas="+col+" Filas="+fil); for(int j=0;j0){ return this.read(px,py-1); }else{ return this.read(px,fil-1); } } float s(){ if(py0){ return this.read(px-1,py); }else{ return this.read(col-1,py); } } float e(){ if(px0){ if(px>0){ return this.read(px-1,py-1); }else{ return this.read(col-1,py-1); } }else{ if(px>0){ return this.read(px-1,fil-1); }else{ return this.read(col-1,fil-1); } } } float ne(){ if(py>0){ if(px0){ return this.read(px-1,py+1); }else{ return this.read(col-1,py+1); } }else{ if(px>0){ return this.read(px-1,0); }else{ return this.read(col-1,0); } } } float se(){ if(py