String[] letters; float x = 0; float y = 0; float timer = 5; int max = 1; Human[] them; int distance = 200; float delta_y = 0; float border; int display_limit = 45; void setup(){ fullScreen(); String[] lines = loadStrings("aurelien-parsed.txt"); letters = (split(lines[0], '-')); them = new Human[letters.length]; border = width*0.2; x = border; y = height*0.9; for(int i = 0; i < letters.length; i++){ if((!letters[i].equals("A") && !letters[i].equals("B") && !letters[i].equals("."))){ y += 60; x = border; } them[i] = new Human(letters[i], x, y, i); x++; if(x > width-border){ y += 20; x = border; } } for(int i = 0; i < them.length-1; i++){ if(them[i].name.equals("A")){ for(int j = i+2; j < them.length-1; j++){ if((them[j].pos.x - them[i].pos.x) < distance && (them[j].pos.x - them[i].pos.x) > 0 && them[i].pos.y == them[j].pos.y && them[j].name.equals("B")){ if(!them[i].name.equals(them[j].name)) them[i].neighbors.add(them[j]); // break; }else{ // them[i].neighbor = them[j]; } } } if(them[i].name.equals("B")){ for(int j = i+2; j < them.length-1; j++){ if((them[j].pos.x - them[i].pos.x) < distance && (them[j].pos.x - them[i].pos.x) > 0 && them[i].pos.y == them[j].pos.y && them[j].name.equals("A")){ if(!them[i].name.equals(them[j].name)) them[i].neighbors.add(them[j]); // break; }else{ // them[i].neighbor = them[j]; } } } } // beginRecord(PDF, "shirt_round"+(int)random(10000)+".pdf"); } void draw(){ background(0); pushMatrix(); translate(0, -delta_y); //scale(0.75); if(delta_y < them[them.length-1].pos.y) delta_y+=2; // noStroke(); for(int i = 0; i < min(display_limit, them.length); i++){ if(them[i].name.equals("A") || them[i].name.equals("B")){ them[i].display(); }else if(!them[i].name.equals(".")){ them[i].chapter(); } } popMatrix(); noCursor(); drawBorders(); if( delta_y % 20 == 0 && display_limit < them.length) display_limit+=1025; } void drawBorders(){ rectMode(CORNER); noStroke(); fill(0, 20); for(int i = 0; i < 40; i++){ rect(0, 0, width, 10+i); } for(int i = 0; i < 40; i++){ rect(0, height, width, -10-i); } } class Human { String name; ArrayList neighbors; PVector pos; int ind; float size; float theta; color col; int alpha; float alpha_coeff; Human(){}; Human(String letter, float x, float y, int i){ name = letter; pos = new PVector(x, y); ind = i; neighbors = new ArrayList(); alpha = 250; alpha_coeff = 0; if(name.equals("A")){ size = 1; col = color(255, 150, 0); }else if(name.equals("B")){ col = color(0, 150, 255); size = 1; }else{ col = color(0, 0, 0); size = 0; } size+=random(4); theta = random(-PI/16, PI/16)+PI/4; } void chapter(){ strokeWeight(1); stroke(180); // line(width*0.2, pos.y-10, width*0.225, pos.y-10); } void display(){ strokeWeight(1); fill(col, 100); // ellipse(pos.x, pos.y, 2+cos(millis()*0.001+ind), 2+cos(millis()*0.001+ind)); // text(name, pos.x, pos.y); strokeCap(PROJECT); // noStroke(); // pushMatrix(); // translate(pos.x, pos.y); // rotate(theta); // if(name.equals("A") || name.equals("B")) // line(-size, 0, size, 0); // popMatrix(); // if(name.equals("A") || name.equals("B")) // ellipse(pos.x, pos.y, size, size); // text(" "+name, pos.x, pos.y); // if(ind < them.length-1 && !name.equals(".")) // line(pos.x, pos.y, them[ind+1].pos.x, them[ind+1].pos.x); // if(neighbor!=null) for(int i = 0; i < neighbors.size(); i++){ stroke(col, map((neighbors.get(i).pos.x - pos.x), 0, distance, alpha, alpha*0.25)*alpha_coeff); // strokeWeight(map((neighbors.get(i).pos.x - pos.x), 0, distance, 10, 1)); line(pos.x, pos.y, neighbors.get(i).pos.x, neighbors.get(i).pos.y); // curve(pos.x, pos.y-noise(i)*100, pos.x, pos.y, pos.x, pos.y, neighbors.get(i).pos.x, neighbors.get(i).pos.y+noise(i)*100); // ellipse(neighbors.get(i).pos.x, neighbors.get(i).pos.y, 10, 10); } if(alpha_coeff < 1) alpha_coeff+=0.01; } } void keyPressed(){ if(key == 'p') saveFrame("aurelien.png"); }