class FacadeElement { //PROPERTIES Area area; float x; //center x coordinate float y; //center y coordinate float eWidth; float eHeight; color eFillColor = color(0,0,0); float eGap = 13; float moveX=0; float moveY=0; boolean fix = false; boolean canChangeStatus = true; //CONSTRUCTORS FacadeElement( Area area) { this.area = area; } //METHODS void addMovement(float dx, float dy) { moveX = moveX +dx; moveY = moveY +dy; } void executeMovement() { setPosition( getX()+moveX, getY()+moveY ); moveX = 0; moveY = 0; } void changeProportion () { float changeP = random (0.95, 1.05); //int tempValue = Filter.getValue( this.x, this.y); //float changeP = (float) map (tempValue, 0,255, 0.7, 1,3); eWidth = eWidth * changeP; eHeight = eHeight / changeP; } void setColor () //setting up algorithms for applying colors { colorMode(HSB); //colorset if (colorset == 1) { this.eFillColor = color (random(255), random(255), random(255)); // all random } //new colorset else if (colorset == 2) { this.eFillColor = color (0, 0, 25+random(200)); //greyscale Ð with constrained extremes } //new colorset else if (colorset == 3) { this.eFillColor = color (0, 127+ random(127), random(128)); //dark-red variation } //new colorset Constrained randomness else if (colorset == 4) { int num = (int) round (random(5)); if(num == 0) { this.eFillColor = color (0, 167+random(20), random(255)); //color1 } else if(num == 1) { this.eFillColor = color (0, 147+random(100), random(64)); //color2 } else if(num == 2) { this.eFillColor = color (0, 127+random(127), random(128)); //color3 } else if(num == 3) { this.eFillColor = color (0, 27+ random(127), random(128)); //color4 } else { this.eFillColor = color (0, random(127), random(128)); //color5 } } //new color set Mondrian else { colorMode(RGB); int num = (int) round (random(7)); if(num == 0) { this.eFillColor = color (254, 0, 0); //color1 } else if(num == 1) { this.eFillColor = color (4, 4, 166); //color2 } else if(num == 2) { this.eFillColor = color (0, 0, 0); //color3 } else if(num == 3) { this.eFillColor = color (254, 254, 0); //color4 } else { this.eFillColor = color (255, 255, 255); //color4 } } } //end setColor void setPosition (float x, float y) { this.x = x; this.y = y; } void setX (float x) { this.x = x; } void setY (float y) { this.y = y; } void setSize (float eWidth, float eHeight) { this.eWidth = eWidth; this.eHeight = eHeight; } void setScale (float scaleFactor) { float newWidth = constrain( this.eWidth *scaleFactor, minWidth, maxWidth); float newHeight = constrain( this.eHeight *scaleFactor, minHeight, maxHeight); this.eWidth = newWidth; this.eHeight = newHeight; } void growGap () //adds distanse that the object want to keep to other object { this.eGap = this.eGap +1; } void shrinkGap () { this.eGap = this.eGap -1; //reduces distanse that the object want to keep to other object } void display () //controls the display of individual objects { if (fix == false) //checking if fixed { fill (this.eFillColor); if (outline==0) { noStroke(); } //sets "fill mode" else { noFill(); stroke (this.eFillColor); } //sets "outline mode" rectMode(CENTER); if (circle==0) { rect (this.x, this.y, eWidth, eHeight ); } //allows change rect/circle. else { ellipse (this.x, this.y, eWidth, eHeight );} } else //fixed element drawing method { //noFill(); //noStroke(); stroke (0); fill (0); //ellipse (this.x, this.y, eWidth, eHeight ); rect (this.x, this.y, eWidth, eHeight ); } } //end void display void displayValue () //prints the brightness of the x,y not used at the moment { Filter cFilter = area.getFilter("SCALE"); color cColor = cFilter.getValue (x, y); //int bright = round ( brightness (cColor)); // String output = " "+ brightness (bright); String output = " "+ (int) brightness (cColor); } float getXmin () //getting edge coorinate from element. { float xmin = this.x-this.eWidth/2; return xmin; } float getXmax () //getting edge coorinate from element. { float xmax = this.x+this.eWidth/2; return xmax; } float getYmin () //getting edge coorinate from element. { float ymin = this.y-this.eHeight/2; return ymin; } float getYmax () //getting edge coorinate from element. { float ymax = this.y+this.eHeight/2; return ymax; } float getWidth () { eWidth = this.eWidth; return eWidth; } float getHeight () { eHeight = this.eHeight; return eWidth; } float getX() { return x; } float getY() { return y; } void fix() { fix=true; } void unfix() { if (canChangeStatus=true) fix = false; } boolean isFix () { return fix; } boolean isOutsideArea( ) //checks if object is outside area. { boolean c1 = this.getXmin()-this.eGap < area.posX; boolean c2 = this.getYmin()-this.eGap < area.posY; boolean c3 = this.getXmax()+this.eGap > area.aWidth + area.posX; boolean c4 = this.getYmax()+this.eGap > area.aHeight + area.posY; if (c1) return true; if (c2) return true; if (c3) return true; if (c4) return true; return false; } //end isOutside area boolean isIntersecting( FacadeElement nE ) //checks for overlap between objects { boolean c1 = nE.getXmin()-nE.eGap <= this.getXmin() && this.getXmin() <= nE.getXmax()+nE.eGap; boolean c2 = nE.getYmin()-nE.eGap <= this.getYmin() && this.getYmin() <= nE.getYmax()+nE.eGap; boolean c3 = nE.getXmin()-nE.eGap <= this.getXmax() && this.getXmax() <= nE.getXmax()+nE.eGap; boolean c4 = nE.getYmin()-nE.eGap <= this.getYmin() && this.getYmin() <= nE.getYmax()+nE.eGap; boolean c5 = nE.getXmin()-nE.eGap <= this.getXmax() && this.getXmax() <= nE.getXmax()+nE.eGap; boolean c6 = nE.getYmin()-nE.eGap <= this.getYmax() && this.getYmax() <= nE.getYmax()+nE.eGap; boolean c7 = nE.getXmin()-nE.eGap <= this.getXmin() && this.getXmin() <= nE.getXmax()+nE.eGap; boolean c8 = nE.getYmin()-nE.eGap <= this.getYmax() && this.getYmax() <= nE.getYmax()+nE.eGap; boolean c10 = nE.getXmin() >= this.getXmin() && this.getXmax() >= nE.getXmax(); // checking if one object is within one other object X wise boolean c11 = nE.getYmin() >= this.getYmin() && this.getYmax() >= nE.getYmax(); // checking if one object is within one other object Y wise if (c1 && c2) return true; if (c3 && c4) return true; if (c5 && c6) return true; if (c7 && c8) return true; if ((c10 && c2) || (c10 && c6)) return true; if ((c11 && c1) || (c11 && c5)) return true; // all checks failed so there's no intersect return false; } //end isIntersecting } //end of class