class BRIGHTER extends Shader { BRIGHTER() { name = "fxBRIGHTER"; params.add(new Param("mode", 2, new int[]{RANDOM})); params.add(new Param("thresh", 60, 180, new int[]{SIN, LINE, RAMPUPDOWN, TAN, COS})); params.add(new Param("thresh2", 120, 200, new int[]{SIN, LINE, RAMPUPDOWN, TAN, COS})); params.add(new Param("brighten", 140, 220, new int[]{SIN, LINE, RAMPUPDOWN, TAN, COS})); /* params.add(new Param("mode", 2)); params.add(new Param("thresh", 60, 180)); params.add(new Param("thresh2", 120, 200)); params.add(new Param("brighten", 140, 220));*/ } /* float inc1, inc2, inc3; float speed; void animate() { inc1+=(speed + .006); inc2+=(speed + .0045); inc3+=(speed + .002); //gui.brickP5.getController("knobOne-"+str(brick)).setValue(int(map(sin(inc1), 2, -1, 0, 255))); //gui.brickP5.getController("knobTwo-"+str(brick)).setValue(int(map(cos(inc2), -1, 1, 0, 255))); //if (mode == 0) { // gui.brickP5.getController("knobThree-"+str(brick)).setValue(int(map(cos(inc2), -1, 1, 0, int(map(cos(inc2), -1, 1, 0, 255))))); //} else if (mode == 1) { // gui.brickP5.getController("knobThree-"+str(brick)).setValue(int(map(cos(inc2), -1, 1, int(map(cos(inc2), -1, 1, 0, 255)), 255 ))); //} if (random(1) > .99) { for (int i = 0; i < params.size(); i++) params.get(i).randomize(); } } */ void apply() { int mode = (int)params.get(0).value; float brighten = params.get(1).value; float thresh = params.get(2).value; float thresh2 = params.get(3).value; renderer.beginDraw(); renderer.colorMode(HSB); colorMode(HSB); renderer.loadPixels(); if (mode == 0) { for (int i = 0; i < renderer.width*renderer.height; i++) { float hue = hue(renderer.pixels[i]); float sat = saturation(renderer.pixels[i]); float bright = brightness(renderer.pixels[i]); if (bright < thresh && bright > thresh2) { bright += brighten; constrain(bright, 0, 255); } color c = color(hue, sat, bright); renderer.pixels[i] = c; } } else if (mode == 1) { for (int i = 0; i < renderer.width*renderer.height; i++) { float hue = hue(renderer.pixels[i]); float sat = saturation(renderer.pixels[i]); float bright = brightness(renderer.pixels[i]); if (bright > thresh && bright < thresh2) { bright += brighten; constrain(bright, 0, 255); } color c = color(hue, sat, bright); renderer.pixels[i] = c; } } renderer.updatePixels(); renderer.colorMode(RGB); colorMode(RGB); renderer.endDraw(); } }