// // name: buddha_fields2.pde // // desc: // // info: bugs, blame and beratement -> <- // // => www.kiddphunk.com/experiments/ // // remember: andre the giant has a posse. // // todo: * nap // /////////////////////////////////////////////////////////////////////////////// ImageSet imageSet; BuddhaImageSet subImageSet; Hashtable2 hash; boolean doPause = false; /////////////////////////////////////////////////////////////////////////////// void setup() { imageSet = new ImageSet(); subImageSet = new BuddhaImageSet(); hash = getVariables(); imageSet.initialize(hash); subImageSet.initialize(hash); subImageSet.loadSet(); } void loop() { if (keyPressed) { if (key == 'r' || key == 'R') { setup(); } if (key == ' ' || key == 'p' || key == 'P') { doPause = !doPause; } } if (!doPause) { subImageSet.incrementCount(); subImageSet.printNextImage(); } } Hashtable2 getVariables() { Hashtable2 hash = new Hashtable2(); hash.put("dimx", 800); // 800 // x-dimention hash.put("dimy", 300); // 300 // y-dimention hash.put("bgcolor_r", 255); // background R hash.put("bgcolor_g", 255); // background G hash.put("bgcolor_b", 255); // background B hash.put("framerate", 30); // framerate hash.put("num_clumping", 30); // 30 // max number of images per clump hash.put("sig_x", 725); // x-position of signature image hash.put("sig_y", 225); // y-position of signature image hash.put("scaling", 300); // 500 // scaling factor hash.put("max_angle", 110); // max angle per clump image hash.put("min_hightint", 35); // 20 // min highlighted image alpha hash.put("max_hightint", 150); // 50 // max highlighted image alpha hash.put("max_tint", 20); // 10 // max regular image alpha hash.put("tint_thresh1", 30); // threshold percent of first image color hash.put("tint_thresh2", 45); // threshold percent of second image color hash.put("tint_thresh3", 80); // threshold percent of third image color hash.put("tint_freq", 51); // every Nth image will be highlighted hash.put("weird_angles", 0); // 0|1 // use weird calculation of angle hash.put("count_startfade", 1500); // loop count when repaint can begin hash.put("count_paintmod", 1000); // loop count when background is repainted hash.put("count_recount", 4000); // loop count when count reset // white on color hash.put("tint_thresh1", 70); hash.put("tint_thresh2", 85); hash.put("tint_thresh3", 99); hash.put("tint_freq", 101); hash.put("scaling", 200); // 500 return hash; } /////////////////////////////////////////////////////////////////////////////// class SubImageSet { color currTint = color(255, 255, 255); BImage sigImage = null; BImage currImage = null; BImage[] images = new BImage[30]; BImage[] highImages = new BImage[30]; int[] percents = new int[30]; int[] percents2 = new int[30]; int[] variables = new int[20]; int numImages = 0; int currIndex = 0; int currScale = 100; int currCount = 0; int coordx = 0; int coordy = 0; int dimx = 0; int dimy = 0; int angle = 0; int cnt = 0; int num = 0; int x, y; Rectangle[] imageBoundaries = new Rectangle[30]; Hashtable2 hash; void SubImageSet() { } void initialize(Hashtable2 hash) { this.hash = hash; this.dimx = hash.get("dimx"); this.dimy = hash.get("dimy"); /* int r = hash.get("bgcolor_r"); int g = hash.get("bgcolor_g"); int b = hash.get("bgcolor_b"); */ int r = int(random(128, 255)); int g = int(random(128, 255)); int b = int(random(128, 255)); framerate(hash.get("framerate")); background(r, g, b); } void incrementCount() { currCount++; int count_startfade = hash.get("count_startfade"); int count_paintmod = hash.get("count_paintmod"); int count_recount = hash.get("count_recount"); if (currCount > count_startfade && (currCount % count_paintmod == 0)) { int r = int(random(128, 255)); int g = int(random(128, 255)); int b = int(random(128, 255)); noStroke(); fill(r, g, b, int(random(90, 99))); rect(0, 0, dimx, dimy); } if (currCount % count_recount == 0) { currCount = 1; } } void printSignature() { if ((currCount == 1) || (currCount % 500) == 0) { if (sigImage != null) { tint(255, 255, 255, 25); image(sigImage, hash.get("sig_x"), hash.get("sig_y"), sigImage.width, sigImage.height); } } } void loadSetImage(String imagename, String highImagename, int percentageSeen, Rectangle boundary) { int current = currentPercentage(); if (percentageSeen + current <= 100) { images[numImages] = loadImage(imagename); highImages[numImages] = (highImagename == "") ? null : loadImage(highImagename); percents2[numImages] = percentageSeen + current; percents[numImages] = percentageSeen; imageBoundaries[numImages] = boundary; numImages++; } } int currentPercentage() { int current = 0; for (int i=0; i 0) { if (hash.get("weird_angles") == 1) { rotateX((angle*cnt)%360); rotateY((angle*cnt)%360); } else { rotateX(((angle*cnt)%360)*2*PI); rotateY(((angle*cnt)%360)*2*PI); } // jiggle x-,y-offset x += int(random(1, 100)-50); y += int(random(1, 100)-50); } else { cnt = int(random(1, hash.get("num_clumping"))); angle = int(random(0, hash.get("max_angle"))); } } void setImageRotation() { } boolean setImageTint() { int tintoff = 0; if (currCount % hash.get("tint_freq") == 0) { tintoff = int(random(hash.get("min_hightint"), hash.get("max_hightint"))); } int t = int(random(hash.get("max_tint"))+tintoff); tint(243, 243, 243, t); if (tintoff > 0) { int rand = int(random(1, 100)); if (rand < hash.get("tint_thresh1")) { tint(255, 255, 255, t); } else if (rand < hash.get("tint_thresh2")) { tint(255, 0, 0, t); } else if (rand < hash.get("tint_thresh3")) { tint(128, 0, 0, t); } else { tint(100, 100, 100, t); } setImageSelection(true); return true; } return false; } void setImageSelection(boolean useHighlight) { int tries = 0; boolean cont = true; while (cont && ++tries<4) { boolean done = false; int index = 0; int rand = int(random(0, 100)); for (int i=0; i= rand) { done = true; } } currIndex = index--; currImage = images[currIndex]; if (useHighlight && (highImages[currIndex] != null)) { currImage = highImages[currIndex]; } Rectangle rect = imageBoundaries[currIndex]; if (rect.contains(x, y)) { cont = false; } } } } ///////////////////////////////////////////////////////////////////////////////