//By Andreas Lahti, a04.andreas.la@ark.lth.se with gratitude to Georg Munkel CAAD ETH ZŸrich // Main Program import processing.pdf.*; Area area; FacadeElement facadeElement; PImage filterPic; int helement = 20; //number of horisontal rect to be crated int velement = 20; //number of horisontal rect to be crated int gap = 5; //sets inital gap beetween objects //int colorset = 3; //chooses the color them (1-4). 1=all-random, 2=greyscale, 3 red-dark variation, 4=colorset1 (constrained random), 5="mondrian painting" int colorset = (int) round (random (4)); String filename = ""; int counter = 0; //controls display of userinterface int circle = 0; // sets drawing method for objects. int outline = 0; // sets fill/outline display int die = 0; boolean stop = true; float minWidth = 4; float maxWidth = 35; float minHeight = 4; float maxHeight = 35; void setup () { smooth(); //PFont font = loadFont("HelveticaNeue-Light-24.vlw"); size (600,600); colorMode(RGB); background(0); ArrayList elementList; area = new Area (); area.createPatternElement (helement, velement, gap); area.createFixedElement (); //area.scaleAllFacadeElements(); //area.compareAllElement(); } //end void setup void draw () { colorMode(RGB); background(0, 0, 0); area.scaleAllFacadeElements(); area.checkAllElementIntersectAndMove(); area.executeMovementAllElements(); area.displayArea(); area.displayAllElement(); counter = counter +1; if (counter<10) { area.displayUserInterface(); } if(keyPressed) // activates filter image display { if (key == 'i' || key == 'I' ) { area.displayFilterImage (); } } // end activate img display } //end void draw //Main user input controll void mouseMoved() // reactivates interface display by reseting counting { counter = 0; } void keyPressed() // activates PDF export { if (key == 's' || key == 'S') { filename = "y" + year () +"_m"+ month() + "_d"+ day() + "_H"+ hour()+ "_M"+ minute()+ "_S"+ second()+ ".pdf"; //sets a timestamp to append on filename. beginRecord(PDF, filename); area.displayArea(); area.displayAllElement(); endRecord(); } } void keyReleased() { if (key == 'c' ||key == 'C') { circle=1; } // switch for changing beetween rect/ellipse drawing method. Quick and dirty as they still recognise eachother as squares if (key == 'r' ||key == 'R') { circle=0; } // switch for changing beetween rect/ellipse drawing method. Quick and dirty as they still recognise eachother as squares if (keyCode == UP) { maxWidth = maxWidth +1; maxHeight = maxHeight +1; } if (keyCode == DOWN) { maxWidth = maxWidth -1; maxHeight = maxHeight -1; } if (keyCode == RIGHT ) { minWidth = minWidth +1; minHeight = minHeight +1; } if (keyCode == LEFT ) { minWidth = minWidth -1; minHeight = minHeight -1; } if (key == 'o' ||key == 'O' ) { outline = 1; } if (key == 'f' ||key == 'F' ) { outline = 0; } if (key == 'g' ) { area.growAllGaps(); } if (key == 'G' ) { area.shrinkAllGaps(); } if (key == 'd' ) { die = 1; } if (key == 'D' ) { die = 0; } } // End keyReleased