|
|
@@ -1009,22 +1009,27 @@ class SLITSCAN extends Shader { |
|
|
|
boolean dox, doy; |
|
|
|
PImage buffer; |
|
|
|
float[][] ft = new float[2][32]; |
|
|
|
int depth; // number of octaves |
|
|
|
//int depth; // number of octaves |
|
|
|
int fxnum; |
|
|
|
int fynum; |
|
|
|
SLITSCAN() { |
|
|
|
name = "fxSlitSscan"; |
|
|
|
buffer = createImage(canvas.width, canvas.height, ARGB); |
|
|
|
|
|
|
|
params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM})); |
|
|
|
directionParamIndex = 0; |
|
|
|
|
|
|
|
buffer = createImage(canvas.width, canvas.height, ARGB); |
|
|
|
int s = (int)(log(min(buffer.width, buffer.height))/log(2)); |
|
|
|
olds = s; |
|
|
|
params.add(new Param("x num", INTVAL, 1, s, new int[]{RANDOM})); |
|
|
|
params.add(new Param("y num", INTVAL, 1, s, new int[]{RANDOM})); |
|
|
|
|
|
|
|
for (int i=0; i<32; i++) { |
|
|
|
ft[0][i] = pow(2.0, i); |
|
|
|
ft[1][i] = 0.5*1.0/ft[0][i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int olds, oldfxnum, oldfynum; |
|
|
|
void apply() { |
|
|
|
canvas.beginDraw(); |
|
|
|
canvas.colorMode(RGB); |
|
|
@@ -1035,12 +1040,20 @@ class SLITSCAN extends Shader { |
|
|
|
buffer = canvas.get(0, 0, canvas.width, canvas.height); |
|
|
|
|
|
|
|
//int s = buffer.width>buffer.height?buffer.height:buffer.width; |
|
|
|
int s = min(buffer.width, buffer.height); |
|
|
|
|
|
|
|
depth = (int)(log(s)/log(2)); |
|
|
|
//int s = min(buffer.width, buffer.height); |
|
|
|
//depth = (int)(log(s)/log(2)); |
|
|
|
|
|
|
|
int s = (int)(log(min(buffer.width, buffer.height))/log(2)); |
|
|
|
if (olds != s) { |
|
|
|
olds = s; |
|
|
|
changeParam(1, new Param("x num", INTVAL, 1, s, new int[]{RANDOM})); |
|
|
|
changeParam(2, new Param("y num", INTVAL, 1, s, new int[]{RANDOM})); |
|
|
|
} |
|
|
|
|
|
|
|
fxnum = (int)random(depth); //// |
|
|
|
fynum = (int)random(depth); //// |
|
|
|
//depth = (int)params.get(1).value; |
|
|
|
//println(depth); |
|
|
|
fxnum = (int)random(params.get(1).value); |
|
|
|
fynum = (int)random(params.get(2).value); |
|
|
|
|
|
|
|
fx = new int[fxnum+1]; |
|
|
|
fy = new int[fynum+1]; |
|
|
@@ -1050,24 +1063,27 @@ class SLITSCAN extends Shader { |
|
|
|
phy = new float[fynum+1]; |
|
|
|
skipfx = new boolean[fxnum+1]; |
|
|
|
skipfy = new boolean[fynum+1]; |
|
|
|
for (int i=0; i<fxnum; i++) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<fxnum; i++) { |
|
|
|
fx[i]=(int)random(6); |
|
|
|
phx[i] = random(1); |
|
|
|
skipfx[i] = random(1)<0.2; |
|
|
|
sx[i] = random(1)<0.2?-1:1; |
|
|
|
} |
|
|
|
for (int i=0; i<fynum; i++) { |
|
|
|
|
|
|
|
fy[i]=(int)random(6); |
|
|
|
phy[i] = random(1); |
|
|
|
skipfy[i] = random(1)<0.2; |
|
|
|
sy[i] = random(1)<0.2?-1:1; |
|
|
|
} |
|
|
|
|
|
|
|
dox = random(1)<0.8; |
|
|
|
doy = dox?random(1)<0.8:true; |
|
|
|
|
|
|
|
//dox = random(1)<0.8; |
|
|
|
//doy = dox?random(1)<0.8:true; |
|
|
|
dox = true; |
|
|
|
doy = true; |
|
|
|
|
|
|
|
|
|
|
|
float v=0; |
|
|
@@ -3311,8 +3327,8 @@ class LENS extends Shader { |
|
|
|
params.add(new Param("lens type y", INTVAL, 0, 3, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("channel x", INTVAL, 0, 11, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("channel y", INTVAL, 0, 11, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("curvature factor x", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("curvature factor y", FLOATVAL, 0, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("curvature factor x", FLOATVAL, 0.01, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("curvature factor y", FLOATVAL, 0.01, 1, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE})); |
|
|
|
params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM})); |
|
|
|
directionParamIndex = 9; |
|
|
|
|
|
|
@@ -4061,3 +4077,163 @@ class STREAKER extends Shader { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
SEGMENTER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
class SEGMENTER extends Shader { |
|
|
|
int thres = 64; // threshold |
|
|
|
int mode = 0; // lighter/darker, essentially 'reverses' the sort |
|
|
|
boolean diag = true; // diagonal/straight |
|
|
|
boolean v = true; // use to select initial direction. |
|
|
|
boolean h = true; // if cycling, use V=true H=false. |
|
|
|
boolean choice = false; |
|
|
|
int iterations; |
|
|
|
PImage img; |
|
|
|
int[] bounds = {0, 0, 0, 0}; |
|
|
|
boolean running = true; |
|
|
|
SEGMENTER() { |
|
|
|
name = "fxSegmenter"; |
|
|
|
params.add(new Param("threshold", INTVAL, 8, 252, new int[]{SINE, TRIANG})); |
|
|
|
params.add(new Param("mode", INTVAL, 0, 1, new int[]{RANDOM, SQUAR})); |
|
|
|
params.add(new Param("diagonal", INTVAL, 0, 1, new int[]{RANDOM, SQUAR})); |
|
|
|
params.add(new Param("horizontal", INTVAL, 0, 1, new int[]{RANDOM, SQUAR})); |
|
|
|
params.add(new Param("vertical", INTVAL, 0, 1, new int[] {RANDOM, SQUAR})); |
|
|
|
params.add(new Param("weirdo pattern mode", INTVAL, 0, 1, new int[] {RANDOM, SQUAR})); |
|
|
|
params.add(new Param("iterations", INTVAL, 1, 100, new int[] {SINE, TRIANG})); |
|
|
|
params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM})); |
|
|
|
directionParamIndex = 7; |
|
|
|
|
|
|
|
|
|
|
|
img = createImage(canvas.width, canvas.height, ARGB); |
|
|
|
canvas.beginDraw(); |
|
|
|
canvas.colorMode(HSB); |
|
|
|
canvas.endDraw(); |
|
|
|
} |
|
|
|
int rw, rh; |
|
|
|
void apply() { |
|
|
|
if (rw != canvas.width || rh != canvas.height) { |
|
|
|
rw = canvas.width; |
|
|
|
rh = canvas.height; |
|
|
|
img.resize(rw, rh); |
|
|
|
bounds[0]= 0; |
|
|
|
bounds[1]= 0; |
|
|
|
bounds[2]= rw; |
|
|
|
bounds[3]= rh; |
|
|
|
} |
|
|
|
img = canvas.get(); |
|
|
|
thres = (int)params.get(0).value; |
|
|
|
mode = (int)params.get(1).value; |
|
|
|
diag = boolean((int)params.get(2).value); |
|
|
|
v = boolean((int)params.get(3).value); |
|
|
|
h = boolean((int)params.get(4).value); |
|
|
|
choice = boolean((int)params.get(5).value); |
|
|
|
iterations = (int)params.get(6).value; |
|
|
|
canvas.beginDraw(); |
|
|
|
canvas.image(img, canvas.width/2, canvas.height/2); |
|
|
|
canvas.endDraw(); |
|
|
|
canvas.beginDraw(); |
|
|
|
|
|
|
|
for (int i = 0; i < iterations; i++) { |
|
|
|
canvas.loadPixels(); |
|
|
|
for (int j = bounds[1]; j < bounds[3]-1; j++) { |
|
|
|
for (int k = bounds[0]; k < bounds[2]-1; k++) { |
|
|
|
float bright = canvas.brightness(canvas.get(k, j)); |
|
|
|
color c; |
|
|
|
if (!choice) { |
|
|
|
if (diag) { |
|
|
|
if (mode == 0) { |
|
|
|
if (h && bright < abs(thres)&& k > bounds[0]+1 && j > bounds[1]+1 && (bright < canvas.brightness(canvas.pixels[k-1+((j-1)*canvas.width)]))) { |
|
|
|
swap(k, j, k-1, j-1); |
|
|
|
} else if (v && bright < abs(thres*2) && j > bounds[1]+1 && k < bounds[2]-1 && (bright < canvas.brightness(canvas.pixels[k+1+((j-1)*canvas.width)]))) { |
|
|
|
swap(k, j, k+1, j-1); |
|
|
|
} else if (h && bright < abs(thres*3) && k < bounds[2]-1 && j < bounds[3]-1 && (bright < canvas.brightness(canvas.pixels[k+1+((j+1)*canvas.width)]))) { |
|
|
|
swap(k, j, k+1, j+1); |
|
|
|
} else if (v && k > bounds[0] && j < bounds[3]-1 && (bright < canvas.brightness(canvas.pixels[k-1+((j+1)*canvas.width)]))) { |
|
|
|
swap(k, j, k-1, j+1); |
|
|
|
} |
|
|
|
} else { // mode |
|
|
|
if (h && bright < abs(thres)&& k > bounds[0] && j > bounds[1] && (bright > canvas.brightness(canvas.pixels[k-1+((j-1)*canvas.width)]))) { |
|
|
|
swap(k, j, k-1, j-1); |
|
|
|
} else if (v && bright < abs(thres*2) && j > bounds[1] && k < bounds[2]-1 && (bright > canvas.brightness(canvas.pixels[k+1+((j-1)*canvas.width)]))) { |
|
|
|
swap(k, j, k+1, j-1); |
|
|
|
} else if (h && bright < abs(thres*3) && k < bounds[2]-1 && j < bounds[3]-1 && (bright > canvas.brightness(canvas.pixels[k+1+((j+1)*canvas.width)]))) { |
|
|
|
swap(k, j, k+1, j+1); |
|
|
|
} else if (v && k > bounds[0] && j < bounds[3]-1 && (bright > canvas.brightness(canvas.pixels[k-1+((j+1)*canvas.width)]))) { |
|
|
|
swap(k, j, k-1, j+1); |
|
|
|
} |
|
|
|
} // mode |
|
|
|
}//diag |
|
|
|
|
|
|
|
else { |
|
|
|
if (mode == 0) { |
|
|
|
if (h && bright < abs(thres)&& k > bounds[0] && (bright < canvas.brightness(canvas.get(k-1, j)))) { |
|
|
|
swap(k, j, k-1, j); |
|
|
|
} else if (v && bright < abs(thres*2) && j > bounds[1] && (bright < canvas.brightness(canvas.get(k, j-1)))) { |
|
|
|
swap(k, j, k, j-1); |
|
|
|
} else if (h && bright < abs(thres*3) && k < bounds[2]-1 && (bright < canvas.brightness(canvas.get(k+1, j)))) { |
|
|
|
swap(k, j, k+1, j); |
|
|
|
} else if (v && k > bounds[0] && j < bounds[3]-1 && (bright < canvas.brightness(canvas.get(k, j+1)))) { |
|
|
|
swap(k, j, k, j+1); |
|
|
|
} |
|
|
|
} else { // mode |
|
|
|
if (h && bright < abs(thres)&& k > bounds[0] && (bright > canvas.brightness(canvas.get(k-1, j)))) { |
|
|
|
swap(k, j, k-1, j); |
|
|
|
} else if (v && bright < abs(thres*2) && j > bounds[1] && (bright > canvas.brightness(canvas.get(k, j-1)))) { |
|
|
|
swap(k, j, k, j-1); |
|
|
|
} else if (h && bright < abs(thres*3) && k < bounds[2]-1 && (bright > canvas.brightness(canvas.get(k+1, j)))) { |
|
|
|
swap(k, j, k+1, j); |
|
|
|
} else if (v && k > bounds[0] && j < bounds[3]-1 && (bright > canvas.brightness(canvas.get(k, j+1)))) { |
|
|
|
swap(k, j, k, j+1); |
|
|
|
} |
|
|
|
} // mode |
|
|
|
} // diag |
|
|
|
} else { //choice |
|
|
|
//weirdo pattern mode |
|
|
|
if (mode == 0) { |
|
|
|
if (bright < thres && k-1+((j-1)*canvas.width) > 0) { |
|
|
|
swap(k, j, k-1, j-1); |
|
|
|
} else if (bright < abs(thres*2) && k+1+((j-1)*canvas.width) > 0) { |
|
|
|
swap(k, j, k+1, j-1); |
|
|
|
} else if (bright < abs(thres*3) && k+1+((j+1)*canvas.width) < canvas.width*canvas.height) { |
|
|
|
swap(k, j, k+1, j+1); |
|
|
|
} else if (k-1+((j+1)*canvas.width) < canvas.width*canvas.height) { |
|
|
|
swap(k, j, k-1, j+1); |
|
|
|
} |
|
|
|
} else { // mode |
|
|
|
if (bright > abs(thres*3) && k-1+((j-1)*canvas.width) > 0) { |
|
|
|
if (k-1+((j-1)*canvas.width) > 0) { |
|
|
|
swap(k, j, k-1, j-1); |
|
|
|
} |
|
|
|
} else |
|
|
|
if (bright > abs(thres*2) && k+1+((j-1)*canvas.width) > 0) { |
|
|
|
if (k+1+((j-1)*canvas.width) > 0) { |
|
|
|
swap(k, j, k+1, j-1); |
|
|
|
} |
|
|
|
} else |
|
|
|
if (bright < thres && k+1+((j+1)*canvas.width) < canvas.width*canvas.height) { |
|
|
|
swap(k, j, k+1, j+1); |
|
|
|
} else if (k-1+((j+1)*canvas.width) < canvas.width*canvas.height) { |
|
|
|
swap(k, j, k-1, j+1); |
|
|
|
} |
|
|
|
} // mode |
|
|
|
}//choice |
|
|
|
}//hori loop |
|
|
|
}//vert loop |
|
|
|
canvas.updatePixels(); |
|
|
|
}//iterations |
|
|
|
canvas.endDraw(); |
|
|
|
} |
|
|
|
|
|
|
|
void swap(int x, int y, int xc, int yc) { |
|
|
|
// if (x+(y*width) < width*height && xc+(yc*width) < width*height && xc+(yc*width) > -1) { |
|
|
|
color c = canvas.pixels[x+(y*canvas.width)]; |
|
|
|
canvas.pixels[x+(y*canvas.width)] = canvas.pixels[xc+(yc*canvas.width)]; |
|
|
|
canvas.pixels[xc+((yc)*canvas.width)] = c; |
|
|
|
// } |
|
|
|
} |
|
|
|
} |