//globals | //globals | ||||
uptime = 116633462 | |||||
uptime = 116634213 |
*/ | */ | ||||
class DISTORTER extends Shader{ | |||||
class DISTORTER extends Shader { | |||||
boolean do_blend = false; // blend image after process | boolean do_blend = false; // blend image after process | ||||
int blend_mode = OVERLAY; // blend type | int blend_mode = OVERLAY; // blend type | ||||
int channel = BRIGHTNESS; // channel used in processing (R,G,B) or (H,S,B) | int channel = BRIGHTNESS; // channel used in processing (R,G,B) or (H,S,B) | ||||
int mode = 0; | int mode = 0; | ||||
DISTORTER() { | DISTORTER() { | ||||
buffer = createImage(renderer.width, renderer.height, ARGB); | 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})); | |||||
name = "fxDistorter"; | |||||
params.add(new Param("width", FLOATVAL, 2, buffer.width/4-1, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG})); | |||||
params.add(new Param("height", FLOATVAL, 2, 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("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 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("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("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})); | params.add(new Param("channel", INTVAL, 0, 12, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG})); | ||||
// channel, blend_mode | |||||
// channel, blend_mode | |||||
//params.add(new Param("height", FLOATVAL, 1, buffer.height/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})); | ||||
// prepare distortion pattern | // prepare distortion pattern | ||||
for (int i=0; i<512; i++) { | for (int i=0; i<512; i++) { | ||||
distort[0][i] = (int)random(-128, 128); | distort[0][i] = (int)random(-128, 128); | ||||
distort[1][i] = (int)random(-128, 128); | distort[1][i] = (int)random(-128, 128); | ||||
} | } | ||||
} | } | ||||
final int[] blends = { | final int[] blends = { | ||||
ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN | ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN | ||||
}; | }; | ||||
final static int NHUE = 9; | final static int NHUE = 9; | ||||
final static int NSATURATION = 10; | final static int NSATURATION = 10; | ||||
final static int NBRIGHTNESS = 11; | final static int NBRIGHTNESS = 11; | ||||
void apply() { | void apply() { | ||||
println(buffer.height); | |||||
buffer = renderer.get(); | buffer = renderer.get(); | ||||
buffer.resize(renderer.width, renderer.height); | buffer.resize(renderer.width, renderer.height); | ||||
scaley = params.get(5).value; | scaley = params.get(5).value; | ||||
blend_mode = blends[(int)params.get(6).value]; | blend_mode = blends[(int)params.get(6).value]; | ||||
channel = (int)params.get(7).value; | channel = (int)params.get(7).value; | ||||
float totalnum = neww+newh; | float totalnum = neww+newh; | ||||
float times = (totalnum/floor(totalnum/neww)); | float times = (totalnum/floor(totalnum/neww)); | ||||
float offx = (totalnum%neww)/times; | float offx = (totalnum%neww)/times; | ||||
float ratiox = neww/buffer.width; | float ratiox = neww/buffer.width; | ||||
println(ratiox); | |||||
renderer.beginDraw(); | renderer.beginDraw(); | ||||
renderer.colorMode(RGB); | |||||
colorMode(RGB); | |||||
renderer.noStroke(); | renderer.noStroke(); | ||||
for (int y=0; y<buffer.height; y++) { | for (int y=0; y<buffer.height; y++) { | ||||
colorMode(RGB, 255); | colorMode(RGB, 255); | ||||
} | } | ||||
// buffer.fill(lerpColor(c,img.get(x,y),0.2)); | // buffer.fill(lerpColor(c,img.get(x,y),0.2)); | ||||
renderer.fill(c); | |||||
renderer.rect(x, y, 1, 1); | |||||
renderer.fill(c); //wärs nich effizienter die pixelmatrix zu ändern ? | |||||
renderer.rect(x, y, 1, 1); | |||||
} | } | ||||
} | } | ||||
return channel>5?255-cc:cc; | return channel>5?255-cc:cc; | ||||
} | } | ||||
} | } |
if (event.getCount() < 0) renderSize += 8; | if (event.getCount() < 0) renderSize += 8; | ||||
else renderSize -= 8; | else renderSize -= 8; | ||||
renderSize = constrain(renderSize, 8, 15000); | renderSize = constrain(renderSize, 8, 15000); | ||||
println("Render size: " + renderSize); | |||||
} | } |
void CP5_pauseAllAction() { | void CP5_pauseAllAction() { | ||||
for(int i = 0; i < bricks.size(); i++){ | |||||
if(!bricks.get(i).paused) bricks.get(i).playPause(); | |||||
for (int i = 0; i < bricks.size(); i++) { | |||||
if (!bricks.get(i).paused) bricks.get(i).playPause(); | |||||
} | } | ||||
} | } | ||||
image(bin, binX, binY, binS, binS); | image(bin, binX, binY, binS, binS); | ||||
stroke(255); | stroke(255); | ||||
strokeWeight(1); | strokeWeight(1); | ||||
textSize(25); | |||||
fill(255); | |||||
text(renderer.width + "x" + renderer.height, 100, height-18); | |||||
textSize(10); | |||||
line(0, height-120, width, height-120); | line(0, height-120, width, height-120); | ||||
totalBrickHeight = 0; | totalBrickHeight = 0; | ||||
for (int i = 0; i < shaderList.size(); i++) { | for (int i = 0; i < shaderList.size(); i++) { | ||||
} | } | ||||
cp5.setPosition(0, height-120); | cp5.setPosition(0, height-120); | ||||
binY = height-85; | |||||
binY = height-87; | |||||
} | } | ||||
class shaderManager { | class shaderManager { | ||||
slider.add(new Slider(10, 20+(20*i)+y, 230, 12, params.get(i).minValue, params.get(i).maxValue, params.get(i).name, params.get(i).type, params.get(i).osciModes)); //add possible waves to slider | slider.add(new Slider(10, 20+(20*i)+y, 230, 12, params.get(i).minValue, params.get(i).maxValue, params.get(i).name, params.get(i).type, params.get(i).osciModes)); //add possible waves to slider | ||||
} | } | ||||
pauseStates = new boolean[slider.size()]; | pauseStates = new boolean[slider.size()]; | ||||
for(int i = 0; i < pauseStates.length; i++){ | |||||
for (int i = 0; i < pauseStates.length; i++) { | |||||
pauseStates[i] = false; | pauseStates[i] = false; | ||||
} | } | ||||
if(!spawnPlaying){ | |||||
if (!spawnPlaying) { | |||||
playPause(); | playPause(); | ||||
} | } | ||||
} | } | ||||
slider.get(sliderNo).setLabel(param.name); | slider.get(sliderNo).setLabel(param.name); | ||||
} | } | ||||
void playPause(){ | |||||
void playPause() { | |||||
paused = !paused; | paused = !paused; | ||||
if(paused){ | |||||
if (paused) { | |||||
pauseAllSliders(); | pauseAllSliders(); | ||||
} else { | } else { | ||||
resumeAllSliders(); | resumeAllSliders(); | ||||
slider.get(i).animated = false; | slider.get(i).animated = false; | ||||
} | } | ||||
} | } | ||||
void resumeAllSliders(){ | |||||
for(int i = 0; i < slider.size(); i++){ | |||||
void resumeAllSliders() { | |||||
for (int i = 0; i < slider.size(); i++) { | |||||
slider.get(i).animated = pauseStates[i]; | slider.get(i).animated = pauseStates[i]; | ||||
} | } | ||||
} | } | ||||
if (slider.get(i).hovering || slider.get(i).hovering_anim_btn) sliderHover = true; | if (slider.get(i).hovering || slider.get(i).hovering_anim_btn) sliderHover = true; | ||||
if (paused && slider.get(i).animated) paused = false; | if (paused && slider.get(i).animated) paused = false; | ||||
} | } | ||||
if(mouseX > 10 && mouseX < 22 && mouseY > 4+totalBrickHeight && mouseY < 4+totalBrickHeight+13){ | |||||
if (mouseX > 10 && mouseX < 22 && mouseY > 4+totalBrickHeight && mouseY < 4+totalBrickHeight+13) { | |||||
hoverActiveButton = true; | hoverActiveButton = true; | ||||
} else { | } else { | ||||
hoverActiveButton = false; | hoverActiveButton = false; | ||||
} | } | ||||
if(mouseX > 25 && mouseX < 37 && mouseY > 4+totalBrickHeight && mouseY < 4+totalBrickHeight+13){ | |||||
if (mouseX > 25 && mouseX < 37 && mouseY > 4+totalBrickHeight && mouseY < 4+totalBrickHeight+13) { | |||||
hoverPauseButton = true; | hoverPauseButton = true; | ||||
} else { | } else { | ||||
hoverPauseButton = false; | hoverPauseButton = false; | ||||
rect(0, totalBrickHeight, width, h); | rect(0, totalBrickHeight, width, h); | ||||
fill(255); | fill(255); | ||||
text(name, 40, 10+totalBrickHeight, 10); | |||||
text(name, 40, 13+totalBrickHeight, 10); | |||||
stroke(255); | stroke(255); | ||||
if (active) fill(185); | if (active) fill(185); | ||||
else noFill(); | else noFill(); | ||||
rect(10, 4+totalBrickHeight, 10, 10); | rect(10, 4+totalBrickHeight, 10, 10); | ||||
if (paused) fill(185); | if (paused) fill(185); | ||||
else noFill(); | else noFill(); | ||||
rect(25,4+totalBrickHeight, 10, 10); | |||||
rect(25, 4+totalBrickHeight, 10, 10); | |||||
for (int i = 0; i < slider.size(); i++) { | for (int i = 0; i < slider.size(); i++) { | ||||
slider.get(i).display(); | slider.get(i).display(); | ||||
fill(185+(40*int(hovering))); | fill(185+(40*int(hovering))); | ||||
rect(x, y, map(value, minVal, maxVal, 0, w), h); | rect(x, y, map(value, minVal, maxVal, 0, w), h); | ||||
fill(255); | fill(255); | ||||
text(label, x+5, y+7); | |||||
text(label, x+5, y+10); | |||||
if (animated) { | if (animated) { | ||||
fill(185+(40*int(hovering_anim_btn))); | fill(185+(40*int(hovering_anim_btn))); | ||||
if (bricks.get(i).hovering) { | if (bricks.get(i).hovering) { | ||||
bricks.get(i).press(); | bricks.get(i).press(); | ||||
} | } | ||||
if(bricks.get(i).hoverActiveButton) bricks.get(i).active = !bricks.get(i).active; | |||||
if(bricks.get(i).hoverPauseButton) bricks.get(i).playPause(); | |||||
if (bricks.get(i).hoverActiveButton) bricks.get(i).active = !bricks.get(i).active; | |||||
if (bricks.get(i).hoverPauseButton) bricks.get(i).playPause(); | |||||
} | } | ||||
} | } | ||||
void mouseDragged() { | void mouseDragged() { | ||||
pressedSlider = -1; | pressedSlider = -1; | ||||
pressedBrick = -1; | pressedBrick = -1; | ||||
} | } | ||||
void mouseWheel(MouseEvent event) { | |||||
if (event.getCount() < 0) renderSize += 8; | |||||
else renderSize -= 8; | |||||
renderSize = constrain(renderSize, 8, 15000); | |||||
} | |||||
} | } |