fixed random oscillator mode
This commit is contained in:
108
effects.pde
108
effects.pde
@@ -8,7 +8,7 @@ class ASDFPIXELSORT extends Shader {
|
||||
ASDFPIXELSORT() {
|
||||
name = "fxASDFPixelSort";
|
||||
params.add(new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("mode", INTVAL, 0, 2, new int[]{RANDOM}));
|
||||
params.add(new Param("target", INTVAL, 0, 2, new int[]{RANDOM}));
|
||||
}
|
||||
int previousMode;
|
||||
|
||||
@@ -17,7 +17,7 @@ class ASDFPIXELSORT extends Shader {
|
||||
if (params.get(1).value == 0) changeParam(0, new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
if (params.get(1).value == 1) changeParam(0, new Param("brightness", INTVAL, 0, 200, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
if (params.get(1).value == 2) changeParam(0, new Param("white", INTVAL, -15000000, -700000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
}
|
||||
}
|
||||
previousMode = int(params.get(1).value);
|
||||
row = 0;
|
||||
column = 0;
|
||||
@@ -290,16 +290,53 @@ class ASDFPIXELSORT extends Shader {
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class DISTORTER extends Shader {
|
||||
class DISTORTER extends Shader{
|
||||
boolean do_blend = false; // blend image after process
|
||||
int blend_mode = OVERLAY; // blend type
|
||||
int channel = BRIGHTNESS; // channel used in processing (R,G,B) or (H,S,B)
|
||||
float scalex = 0.05; // from 0.01 to 1
|
||||
float scaley = 0.1; // from 0.01 to 1
|
||||
boolean shift_hue = true;
|
||||
float shift_amt = 0.1; // from 0 to 1
|
||||
|
||||
PImage buffer;
|
||||
|
||||
|
||||
int[][] distort = new int[2][512];
|
||||
final static float tick = 1.0/512.0;
|
||||
|
||||
int mode = 0;
|
||||
|
||||
DISTORTER() {
|
||||
|
||||
buffer = createImage(renderer.width, renderer.height, ARGB);
|
||||
name = "fxDIstorter";
|
||||
params.add(new Param("width", FLOATVAL, 1, buffer.width/4-1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("height", FLOATVAL, 1, buffer.height/4-1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("do blend", INTVAL, 0, 1, new int[]{RANDOM,SQUAR}));
|
||||
params.add(new Param("shift hue amount", FLOATVAL, 0, 1, new int[]{SAWTOOTH, SAWTOOTHINVERSE, TAN, TANINVERSE, RAMP, RAMPINVERSE}));
|
||||
params.add(new Param("scale x", FLOATVAL, 0.01, 1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("scale y", FLOATVAL, 0.01, 1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("blend mode", INTVAL, 0, 11, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
params.add(new Param("channel", INTVAL, 0, 12, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
|
||||
// channel, blend_mode
|
||||
|
||||
//params.add(new Param("height", FLOATVAL, 1, buffer.height/4-1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||
|
||||
|
||||
// prepare distortion pattern
|
||||
for (int i=0; i<512; i++) {
|
||||
distort[0][i] = (int)random(-128, 128);
|
||||
distort[1][i] = (int)random(-128, 128);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final int[] blends = {
|
||||
ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN
|
||||
};
|
||||
|
||||
// ALL Channels, Nxxx stand for negative (255-value)
|
||||
// channels to work with
|
||||
final static int RED = 0;
|
||||
@@ -314,40 +351,30 @@ class DISTORTER extends Shader {
|
||||
final static int NHUE = 9;
|
||||
final static int NSATURATION = 10;
|
||||
final static int NBRIGHTNESS = 11;
|
||||
|
||||
DISTORTER() {
|
||||
name = "fxDistorter";
|
||||
/*
|
||||
//params.add(new Param ("shifthue", 1)); //boolean shift_hue
|
||||
params.add(new Param("hueshift", 0, 1)); //float shift_amt
|
||||
params.add(new Param("scalex", 0.01, 1)); //float scalex
|
||||
params.add(new Param("scaley", 0.01, 1)); //float scaley
|
||||
//params.add(new Param ("blend", 1)); //boolean do_blend
|
||||
params.add(new Param ("blendmode", blends.length)); //int blend_mode
|
||||
params.add(new Param("channel", 12));*/
|
||||
|
||||
buffer = createImage(renderer.width, renderer.height, ARGB);
|
||||
|
||||
// prepare distortion pattern
|
||||
for (int i=0; i<512; i++) {
|
||||
distort[0][i] = (int)random(-128, 128);
|
||||
distort[1][i] = (int)random(-128, 128);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void apply() {
|
||||
|
||||
buffer = renderer.get();
|
||||
buffer.resize(renderer.width, renderer.height);
|
||||
|
||||
float neww = map(params.get(1).value, 0, 1, 1, buffer.width/4);
|
||||
float newh = map(params.get(2).value, 0, 1, 1, buffer.height/4);
|
||||
|
||||
float neww = params.get(0).value;
|
||||
float newh = params.get(1).value;
|
||||
do_blend = boolean(int(params.get(2).value));
|
||||
shift_amt = params.get(3).value;
|
||||
scalex = params.get(4).value;
|
||||
scaley = params.get(5).value;
|
||||
blend_mode = blends[(int)params.get(6).value];
|
||||
channel = (int)params.get(7).value;
|
||||
|
||||
|
||||
float totalnum = neww+newh;
|
||||
float times = (totalnum/floor(totalnum/neww));
|
||||
float offx = (totalnum%neww)/times;
|
||||
float ratiox = neww/buffer.width;
|
||||
|
||||
renderer.beginDraw();
|
||||
renderer.colorMode(RGB);
|
||||
colorMode(RGB);
|
||||
renderer.noStroke();
|
||||
|
||||
for (int y=0; y<buffer.height; y++) {
|
||||
@@ -367,27 +394,26 @@ class DISTORTER extends Shader {
|
||||
float cx = lerp(distort[0][no1], distort[0][no2], l);
|
||||
float cy = lerp(distort[1][no1], distort[1][no2], l);
|
||||
|
||||
float rx =getChannel(buffer.get(x, y), (int)params.get(4).value);
|
||||
int sx = (int)((buffer.width+x+cx*rx*params.get(1).value*0.1)%buffer.width);
|
||||
int sy = (int)((buffer.height+y+cy*params.get(0).value)%buffer.height);
|
||||
float rx =getChannel(buffer.get(x, y), channel);
|
||||
int sx = (int)((buffer.width+x+cx*rx*scalex*0.1)%buffer.width);
|
||||
int sy = (int)((buffer.height+y+cy*scaley)%buffer.height);
|
||||
|
||||
color c=buffer.get(sx, sy);
|
||||
|
||||
//if (boolean((int)(params.get(0).value))) {
|
||||
colorMode(HSB, 255);
|
||||
c = color((hue(c)+params.get(0).value*255*noise(newh+y))%255.0, constrain(saturation(c)*1.2, 0, 255), constrain(brightness(c), 0, 255));
|
||||
colorMode(RGB, 255);
|
||||
//}
|
||||
//renderer.fill(lerpColor(c,buffer.get(x,y),0.2));
|
||||
if (shift_hue) {
|
||||
colorMode(HSB, 255);
|
||||
c = color((hue(c)+shift_amt*255*noise(newh+y))%255.0, constrain(saturation(c)*1.2, 0, 255), constrain(brightness(c), 0, 255));
|
||||
colorMode(RGB, 255);
|
||||
}
|
||||
// buffer.fill(lerpColor(c,img.get(x,y),0.2));
|
||||
renderer.fill(c);
|
||||
renderer.rect(x, y, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//if (boolean((int)(params.get(4).value)))
|
||||
renderer.blend(buffer, 0, 0, buffer.width, buffer.height, 0, 0, renderer.width, renderer.height, (int)params.get(3).value);
|
||||
if (do_blend)
|
||||
renderer.blend(buffer, 0, 0, buffer.width, buffer.height, 0, 0, renderer.width, renderer.height, blend_mode);
|
||||
|
||||
colorMode(RGB);
|
||||
renderer.endDraw();
|
||||
}
|
||||
|
||||
@@ -420,4 +446,6 @@ class DISTORTER extends Shader {
|
||||
|
||||
return channel>5?255-cc:cc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user