//AlcysCubeConvolution //point de départ : Edge Detection by REAS //convolutions : http://www.dunwich.org/batiste/sic/ecms/ecfrfull.html // //------------------------------------------------------------------------- //------------------------------------------------------------------------- BImage a; BImage[] tampon; int w, h, coefficient1, coefficient2; int[] cc, dd; float za, zb,cza,czb, angle, incangle,rotx,roty; void setup() { a= loadImage("acc.jpg"); w= a.width; h= a.height; size(400,400); cza=0.000004f;za=0.0005f; czb=-.000001f;zb=-0.0025f; angle= 0.2f; incangle= 0.00001f; cc= new int[] { 0x339999, 0x120000, 0x000001, 0x887979}; dd= new int[] { 0xf01130, 0xf0f0f0, 0x606060, 0xc0b4b3}; tampon= new BImage[6]; for (int i= 0; i < 4; i++) { tampon[i]= new BImage(w, h); } } // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° void loop() { clear(); roty+=0.03f; if (angle > 0.5 || angle < 0.05) incangle *= -1; angle += incangle; //za+= cza*cos(angle) ; zb+= czb*cos(angle); calculerTampon(); push(); translate(200,250,-400); rotateY(roty); noStroke(); tampon[0].alpha(tampon[0]); boite(380); pop(); } // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° void calculerTampon() { for (int i= 0; i < 4; i++) { coefficient1= cc[i]; coefficient2= dd[i]; for (int y= 0; y < a.height; y++) { for (int x= 0; x < a.width; x++) { float somme= zb * filtre(x, y) + za * (filtre(x - 1, y) + filtre( x + 1, y) + filtre( x, y - 1) + filtre( x, y + 1)); tampon[i].pixels[x + w * y]= Math.round(somme); } } } } //°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° float filtre(int x, int y) { x= (x < 0) ? 0 : x; x= (x >= a.width - 1) ? a.width - 1 : x; y= (y < 0) ? 0 : y; y= (y >= a.height - 1) ? a.height - 1 : y; return (coefficient1 | (coefficient2 & a.get(x, y))); } //°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° void mouseReleased() { roty=(mouseX-width)/200; za=0.005f * mouseX / width; zb=-0.02f * mouseY / height; } // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° void boite(float d){ beginShape(QUADS); tampon[0].alpha(tampon[0]); texture(tampon[0]); vertex(-d, -d, -d, 0, 0); vertex(d, -d, -d, tampon[0].width, 0); vertex(d, d, -d, tampon[0].width, tampon[0].height); vertex(-d, d, -d, 0, tampon[0].height); endShape(); beginShape(QUADS); tampon[1].alpha(tampon[1]);texture(tampon[1]); vertex(-d, -d, d,0,0); vertex(d, -d, d, tampon[1].height,0); vertex(d,d, d, tampon[1].width, tampon[1].height); vertex(-d, d, d, 0,tampon[1].width); endShape(); beginShape(QUADS); tampon[2].alpha(tampon[2]);texture(tampon[2]); vertex(-d, -d, d, 0, 0); vertex(-d, -d, -d, tampon[2].width, 0); vertex(-d, d, -d, tampon[2].width, tampon[2].height); vertex(-d, d, d, 0, tampon[2].height); endShape(); beginShape(QUADS); tampon[3].alpha(tampon[3]);texture(tampon[3]); vertex(d, -d, -d, 0, 0); vertex(d, -d, d, tampon[3].width, 0); vertex(d, d, d, tampon[3].width, tampon[3].height); vertex(d, d, -d, 0, tampon[3].height); endShape(); } //°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°