/** * Copyright (c) 2010 LAFKON/Benjamin Stephan. * * This is free software, and you may redistribute it under the GPL. * This Software comes with absolutely no warranty. * For details see the license (http://www.lafkon.net/gpl.txt) * * http://www.forkable.eu/generators/va300/ * http://www.lafkon.net/what/is/va300 */ // This is the live-version, made for continuous live projection! // For a pdf-outputting-version check the URLs above. import fisica.*; import geomerative.*; import ijeoma.motion.*; import ijeoma.motion.tween.*; float x,y,x1,x2,y1,y2; RShape shp; RPoint[] points; RPoint[][] pointPaths; String[]vektorlist, singletonList; PGraphics canvas; boolean firstRun = true; ArrayList traceBodies, singletonBodies, allBodies; FWorld world; FPolyPlus poly; FPolyMinus polym; FPolyMinus obstacle, obstacle02, obstacle03, obstacle04; Tween t; TweenParallel tp; //=========================================== boolean invert = false; // black white //=========================================== String outputFormat, typosize, inverted; int gravityy = 100; int gravityx = 0; float rndx; float wert = 1; float wert2 = 0.5; float wert3 = 0; float wert4 = 5; float rot = 0; public float eraserecty = 0; public float obstX, obstY, obstNextX, obstNextY, obstR, obstNextR; void setup() { size(580, 850, JAVA2D); smooth(); frameRate(100); if(firstRun) { outputFormat = loadStrings("i/posterformat.i")[0]; typosize = loadStrings("i/typosize.i")[0]; vektorlist = loadStrings("i/participants_" +typosize +".list"); singletonList = loadStrings("i/info.list"); Collections.shuffle(Arrays.asList(vektorlist)); } //============================================== WORLD init ==== if(firstRun) { Fisica.init(this); RG.init(this); Motion.setup(this); world = new FWorld(); world.setGravity(0, 100); world.setEdges(); world.remove(world.top); world.top.setDrawable(false); world.left.setDrawable(false); world.right.setDrawable(false); world.bottom.setDrawable(false); world.setEdgesRestitution(0.8); world.setEdgesFriction(100); world.bottom.setGrabbable(true); world.bottom.setDensity(100); world.bottom.setDamping(0); world.bottom.setRestitution(0.81); world.bottom.setFriction(wert2); traceBodies = new ArrayList(); singletonBodies = new ArrayList(); allBodies = new ArrayList(); } //============================================== SINGLETONS init ==== if(firstRun) { for(int k=0; k start over again (5th step) reset(); } else { //set tween values noStroke(); if(invert) fill(0,0,0); else fill(255); ellipseMode(RADIUS); ellipse(obstacle.getX()+40, obstacle.getY()+40, eraserecty, eraserecty); obstacle.setPosition(obstX, obstY); obstacle.setRotation(obstR); } } // advance simulation and draw world world.step(); if(frameCount%1 == 0) { //draw every n-th frame only world.draw(canvas); } }//draw end void reset() { frameCount = 0; eraserecty = 0; setup(); } //=================================================== UTILS =========== RPoint[] unionPath(RShape shp) { RPoint[][] shapo = shp.getPointsInPaths(); ArrayList polys = new ArrayList(); RPolygon unionPoly = new RPolygon(); for(int i = 0; i < shapo.length; i++) { RPolygon rpoly = new RPolygon(shapo[i]); polys.add(rpoly); } for(int i = 0; i < polys.size(); i++) { RPolygon p = (RPolygon) polys.get(i); unionPoly = unionPoly.union(p); } return unionPoly.getPoints(); } RShape loadRShape(String svgpath) { RShape svgload; RG.ignoreStyles(true); //RG.setPolygonizer(RG.UNIFORMSTEP); svgload = RG.loadShape(svgpath); return svgload; }