added fxDripDrip
This commit is contained in:
98
effects.pde
98
effects.pde
@@ -2494,6 +2494,7 @@ class PIXELDRIFTER extends Shader {
|
||||
params.add(new Param ("do blend", INTVAL, 0, 1, new int[]{RANDOM, SQUAR}));
|
||||
params.add(new Param ("blend mode", INTVAL, 0, blends.length-1, new int[]{RANDOM}));
|
||||
params.add(new Param ("channel", INTVAL, 0, 1, new int[]{SQUAR, RANDOM}));
|
||||
params.add(new Param ("automate channel offset", INTVAL, 0, 1, new int[]{SQUAR, RANDOM}));
|
||||
rw = canvas.width;
|
||||
rh = canvas.height;
|
||||
|
||||
@@ -2508,7 +2509,6 @@ class PIXELDRIFTER extends Shader {
|
||||
buffer.endDraw();
|
||||
|
||||
scale = abs(scale);
|
||||
acho_step = 256.0 / iteration_no;
|
||||
}
|
||||
|
||||
void apply() {
|
||||
@@ -2527,6 +2527,8 @@ class PIXELDRIFTER extends Shader {
|
||||
do_blend = boolean((int)params.get(5).value);
|
||||
blend_mode = blends[(int)params.get(6).value];
|
||||
channel = (int)params.get(7).value == 1 ? HUE : RGB;
|
||||
automate_channel_offset = boolean((int)params.get(8).value);
|
||||
acho_step = 256.0 / iteration_no;
|
||||
|
||||
img = canvas.get();
|
||||
|
||||
@@ -2616,8 +2618,102 @@ class PIXELDRIFTER extends Shader {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
DRIPDRIP
|
||||
|
||||
*/
|
||||
|
||||
class DRIPDRIP extends Shader {
|
||||
int maxsteps = 50; //maximum fade length in px
|
||||
int minsteps = 2; //minimum fade length in px
|
||||
Boolean brightmode = false; //if enabled will fade light over dark
|
||||
Boolean autotoggle = true; //switch brightmode at pivot point
|
||||
float autoPivot = 0.58; //where on the y axis (0-1) to switch
|
||||
int steps[];
|
||||
int rw, rh;
|
||||
DRIPDRIP() {
|
||||
name = "fxDripDrip";
|
||||
params.add(new Param ("max steps", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("min steps", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param ("bright breakpoint", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
|
||||
//params.add(new Param ("auto toggle", INTVAL, 0, 1, new int[]{SQUAR, RANDOM}));
|
||||
params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM}));
|
||||
directionParamIndex = 3;
|
||||
rw = canvas.width;
|
||||
rh = canvas.height;
|
||||
steps = new int[canvas.width*canvas.height];
|
||||
|
||||
for (int i = 0; i < canvas.width*canvas.height; i++) {
|
||||
steps[i] = (int)map(random(1), 0, 1, minsteps, maxsteps);
|
||||
}
|
||||
}
|
||||
|
||||
void apply() {
|
||||
minsteps = (int)map(params.get(1).value, 0, 1, 1, max(canvas.width, canvas.height)/10);
|
||||
maxsteps = (int)map(params.get(0).value, 0, 1, minsteps, max(canvas.width, canvas.height)/10);
|
||||
autoPivot = params.get(2).value;
|
||||
//brightmode = boolean((int)params.get(3).value);
|
||||
//autotoggle = boolean((int)params.get(4).value);
|
||||
if (rw != canvas.width || rh != canvas.height) {
|
||||
rw = canvas.width;
|
||||
rh = canvas.height;
|
||||
|
||||
steps = new int[canvas.width*canvas.height];
|
||||
}
|
||||
for (int i = 0; i < steps.length; i++) {
|
||||
steps[i] = (int)map(random(1), 0, 1, minsteps, maxsteps);
|
||||
}
|
||||
|
||||
canvas.beginDraw();
|
||||
canvas.loadPixels();
|
||||
|
||||
for ( int x = 0, w = canvas.width; x<w; x++) {
|
||||
for ( int h = canvas.height, y = h-1; y>-1; y--) {
|
||||
/*
|
||||
if ( alternatetoggle ) {
|
||||
brightmode = !brightmode;
|
||||
} else {
|
||||
if ( autotoggle ) {
|
||||
brightmode = y > (h*autoPivot);
|
||||
}
|
||||
}
|
||||
*/
|
||||
//if (autotoggle) {
|
||||
brightmode = y > (h*autoPivot);
|
||||
//}
|
||||
|
||||
float rat = 1.0;
|
||||
int pos = x + y * w;
|
||||
color c = canvas.pixels[pos];
|
||||
int ty = y;
|
||||
|
||||
while ( rat > 1.0/steps[x*y]*2 ) {
|
||||
ty++;
|
||||
if ( ty >= h ) break;
|
||||
int tpos = x + ty * w;
|
||||
color tc = canvas.pixels[tpos];
|
||||
if (
|
||||
( !brightmode && brightness(tc) < brightness(c) )
|
||||
|| ( brightmode && brightness(tc) > brightness(c) )
|
||||
) break;
|
||||
canvas.pixels[tpos] = blendC(tc, c, rat);
|
||||
rat-= rat/steps[x*y];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canvas.updatePixels();
|
||||
canvas.endDraw();
|
||||
}
|
||||
color blendC(color tc, color sc, float rat) {
|
||||
return color(
|
||||
(red(tc)*(1.0-rat))+(red(sc)*rat),
|
||||
(green(tc)*(1.0-rat))+(green(sc)*rat),
|
||||
(blue(tc)*(1.0-rat))+(blue(sc)*rat)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -601,6 +601,9 @@ public class SecondApplet extends PApplet {
|
||||
case(22):
|
||||
shaderManager.addShader(new PIXELDRIFTER());
|
||||
break;
|
||||
case(23):
|
||||
shaderManager.addShader(new DRIPDRIP());
|
||||
break;
|
||||
/*
|
||||
case(4):
|
||||
shaderManager.addShader(new AUECHO());
|
||||
|
||||
@@ -67,5 +67,5 @@ String availableFx[] = {
|
||||
"fxDrawStrokes",
|
||||
"fxDrawGenerative",
|
||||
"fxPixelDrifter",
|
||||
"fxMosh"
|
||||
"fxDripDrip"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user