import gifAnimation.*; import java.awt.event.*; Gif[][][][] gifs; PImage tile; //String clivar[] = loadStrings("i/clivar.ctrl"); //int vertlines = int(clivar[0]); //int horlines = int(clivar[1]); //println(vertlines + "x" + horlines); int vertlines = 5; int horlines = 4; int iid = 1; int jid = 1; int sid = 1; int tileid = 0; int tileselect; String listdir = "i/free/multilist/5x4/134616999993594"; int alphaval = 100; int mousewheel,mousewheelbefore,tileidbefore; int imgid[][][]; int variation = 4 ; int sets = 2 ; boolean mousewheelmoved = false; boolean forward = false; boolean mousepressed = false; color activated; void setup() { size(500,700); frameRate(15); smooth(); // add mouse wheel listener frame.addMouseWheelListener(new MouseWheelInput()); mousewheel = 0; gifs = new Gif[3][horlines][vertlines+1][variation]; imgid = new int[3][horlines][vertlines+1]; reboot(); noStroke(); } void draw() { /* background(255); translate(10,90); scale(0.90); pushMatrix(); // pushMatrix(); // // translate(-30,height-180); // scale(width/595.0); // // popMatrix(); pushMatrix(); translate(100.0/horlines,height-230); scale(width/(99.0*horlines)); for (int j=1; j <= vertlines; j++) { for (int i=1; i <= gifs.length; i++) { //-----------------------------------------// if ( (mousewheel > mousewheelbefore) && (!mousePressed) ) { //tileid--; iid--; mousewheelmoved = true ; forward = true; activated = color(255,0,0); } else if ( (mousewheel < mousewheelbefore) && (!mousePressed) ) { //tileid++; iid++; mousewheelmoved = true ; forward = false; activated = color(0,255,0); }; mousewheelbefore = mousewheel; if ( iid > horlines ) { jid++; iid = 1; if ( jid > vertlines ) { jid = 1; } } if ( iid < 1 ) { jid--; iid = horlines; if ( jid < 1 ) { jid = vertlines; } } //println("iid: " + iid); //println("jid: " + jid); //println("tileid: " + tileid); //println("mousewheel: " + mousewheel); //println("tileselect: " + tileselect); //println(); if ( mousewheelmoved == true ) { mousewheelmoved = false ; //println("MOUSEWHEEL MOVED!"); alphaval = 50; } if ( (j == jid) && (i == iid) ) { // if (tileid != tileidbefore) { if (mousepressed) { activated = color(255,255,0); alphaval = 150; tileid++; println("JETZT MAL NEU!" + tileid); if ( tileid >= variation ) { tileid = 1; } if ( tileid <= 0 ) { tileid = variation - 1; } mousepressed = false; } else { tileid = imgid[sid][i-1][j]; } imgid[sid][i-1][j] = tileid ; // println("j:" + j + " i:" + i); //println("imgid: " + imgid[i-1][j]); // } tile = gifs[sid][i-1][j][imgid[sid][i-1][j]]; image(tile, 0, 0); fill(activated,alphaval); rect(0,0,gifs[sid][i-1][j][imgid[sid][i-1][j]].width,gifs[sid][i-1][j][imgid[sid][i-1][j]].height); } else { //println("imgid: " + imgid[i-1][j]); //imgid[i-1][j] = imgid[i-1][j] ; tile = gifs[sid][i-1][j][imgid[sid][i-1][j]]; image(tile, 0, 0); //println(imgid[i-1][j]); } translate(99,0); } translate(gifs.length*-99,-99); } popMatrix(); popMatrix(); alphaval = max(alphaval - 5,0); */ background(255); translate(10,90); scale(0.90); pushMatrix(); pushMatrix(); translate(100.0/horlines,height-230); scale(width/(99.0*horlines)); for (int j=1; j <= vertlines; j++) { //for (int i=1; i <= gifs.length; i++) { for (int i=1; i <= 3; i++) { //tile = gifs[sid][i-1][j][imgid[sid][i-1][j]]; //tile = gifs[sid][i-1][j][1]; //image(tile, 0, 0); fill(255,0,0); rect(0,0,100,100); translate(99,0); } translate(gifs.length*-99,-99); } popMatrix(); popMatrix(); } void mousePressed() { if (mouseButton == RIGHT ) { mousepressed = true; } } void reboot() { /* while ( int(loadStrings("i/pause.i")[0]) < 1 ) { println("unactive"); } */ for (int l=1; l <= sets ; l++) { for (int j=1; j <= vertlines; j++) { String liste = str(j); //String lines[] = loadStrings(listdir + "/" + //+ vertlines + "x" + horlines + "/" + liste + ".list"); String lines[] = loadStrings(listdir + "/" + liste + ".list"); for (int i=0; i < lines.length; i++) { String files[] = loadStrings(lines[i]); //println(lines[i]); for (int k=0; k < variation ; k++) { //println(files[k]); gifs[l][i][j][k] = new Gif(this, files[k]); gifs[l][i][j][k].play(); imgid[l][i][j] = int (random(1,variation)); } } } } } class MouseWheelInput implements MouseWheelListener{ void mouseWheelMoved(MouseWheelEvent e) { int step=e.getWheelRotation(); mousewheel=mousewheel+step; } }