class Filter { //PROPERTIES //PImage filterPic; Area area; //CONSTRUCTORS Filter (Area area) { this.area = area; loadFilterImage (); } //METHODS void loadFilterImage () { String imgName = " "; int nPic = (int)round(random(10)); //sets a random number for choosing the image. imgName = "scale" + nPic + ".jpg"; //println (imgName); filterPic = loadImage(imgName); //filterPic = loadImage("scale2.gif"); //filterPic = loadImage("scale2.jpg"); //filterPic2 = loadImage("move.jpg"); } color getValue(float x, float y) { int px = round ( map (x, area.posX, area.posX+area.getWidth(), 0, filterPic.width) ); int py = round ( map (y, area.posY, area.posY+area.getHeight(), 0, filterPic.height) ); color cColor = (int) brightness(filterPic.get (px, py)); return cColor; } float setFilterScale (float x, float y) //sets the scale factor of scalefilter { //Filter cFilter = area.getFilter("SCALE"); //color cColor = (int) brightness(getValue (x, y)); //int scalefactor = (int) brightness (cColor); //float scalefactor = (float) map (cColor, 0, 255 , 0.0, 2.0); float xpos = x; float ypos = y; int cColor = getValue(xpos, ypos); float scalefactor = 167/cColor; return scalefactor; } /* not implemented yet float setFilterMove (float x, float y) //sets the motion of scalefilter { float xpos = x; float ypos = y; int cColor = getValue(xpos, ypos); int cColorUpLeft = getValue(xpos-getWidth/2, ypos-getHeight/2); int cColorUpRight = getValue(xpos+getWidth/2, ypos+getHeight/2); int cColorDownRight = getValue(xpos+getWidth/2, ypos-getHeight/2); int cColorDownLeft = getValue(xpos-getWidth/2, ypos-getHeight/2); //cColor-cColorUpLeft = float scalefactor = 127/cColor; return scalefactor; } */ }