/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Interface Fractures III - SILICON (c) nova@deviator.si functions.pde */ // loads all images into an array - - - - - - - - - - - - - - - - - - - - - - - - - PImage[][] getImages(String folder) { PImage[][] imgPool; // declare 2D array imgPool File dir = new File(dataPath(sketchPath + folder)); // first folder String[] dirlist = dir.list(); // an array of folders (strings) dirlist = sort(dirlist); // imgPool = new PImage[dirlist.length][10]; // create 2d array imgPool for (int i = 0; i < dirlist.length; i++) { String fulldir = dataPath(sketchPath + folder + dirlist[i]) + "/"; File dir2 = new File(fulldir); String[] filelist = dir2.list(); // an array of image names filelist = sort(filelist); if (filelist.length != 0) { for (int j = 0; j < filelist.length; j++) { println("imgPool[" + i + "][" + j + "]: " + fulldir + filelist[j]); imgPool[i][j] = loadImage(fulldir + filelist[j]); } } else { println("No files in this folder: " + fulldir); } } return imgPool; } // function to shuffle an array of integers - - - - - - - - - - - - - - - - - - - - - void shuffle(int[] a) { int temp, pick; for(int i=0; i- more TO BE EXPANDED / REFINED!!! */ void testPattern( boolean render, int imgBank, int imgID, int imgAlpha, int ylines, int density, int lwidth, int lalpha, int speed ) { if (render) { tint(imgAlpha); image(imgPool[imgBank][imgID], 0, 0); blendMode(BLEND); int yheight = height/ylines; for (int y=0; y < ylines; y++) { int yloc = int((y+1)*height/(ylines+1)); for (int x=0; x < width; x++) { int index = x + (y * (width/ylines)); index = index % width; if (randz.get(index) < density * 0.01 * randz.get((index + x + y) % randz.size())) { int fx = (x + frameCount); // move! fx = fx * speed * 1 * randz.get((abs(index - x + y) % randz.size())) / randz.size(); // speed! fx %= width; // wrap at the right edge color imgC = imgPool[imgBank][imgID].get(fx, yloc); stroke(imgC, lalpha); strokeWeight(1 + map(brightness(imgC), 0, 255, 0, lwidth)); line(fx, yheight * y + (yheight/30), fx, yheight * (y+1) - (yheight/30)); } } } } } // SPHERES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // A 3D textured sphere with simple rotation control. // thanks to https://processing.org/examples/texturesphere.html // Texture Sphere written by Gillian Ramsay to better display the poles. // Previous version by Mike 'Flux' Chang (and cleaned up by Aaron Koblin). // Original based on code by Toxi. // modified to accomodate offscreen PGraphics void initializeSphere(int numPtsW, int numPtsH_2pi) { // The number of points around the width and height numPointsW=numPtsW+1; numPointsH_2pi=numPtsH_2pi; // How many actual pts around the sphere (not just from top to bottom) numPointsH=ceil((float)numPointsH_2pi/2)+1; // How many pts from top to bottom (abs(....) b/c of the possibility of an odd numPointsH_2pi) coorX=new float[numPointsW]; // All the x-coor in a horizontal circle radius 1 coorY=new float[numPointsH]; // All the y-coor in a vertical circle radius 1 coorZ=new float[numPointsW]; // All the z-coor in a horizontal circle radius 1 multXZ=new float[numPointsH]; // The radius of each horizontal circle (that you will multiply with coorX and coorZ) for (int i=0; i