/* ASDFPIXELSORT */ 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("target", INTVAL, 0, 2, new int[]{RANDOM})); } int previousMode; void apply() { if (previousMode != int(params.get(1).value)) { 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; renderer.beginDraw(); renderer.colorMode(RGB); colorMode(RGB); while (column < renderer.width-1) { renderer.loadPixels(); sortColumn(); column++; renderer.updatePixels(); } while (row < renderer.height-1) { renderer.loadPixels(); sortRow(); row++; renderer.updatePixels(); } renderer.endDraw(); } int row = 0; int column = 0; void sortRow() { int x = 0; int y = row; int xend = 0; while (xend < renderer.width-1) { switch((int)params.get(1).value) { case 0: x = getFirstNotBlackX(x, y); xend = getNextBlackX(x, y); break; case 1: x = getFirstBrightX(x, y); xend = getNextDarkX(x, y); break; case 2: x = getFirstNotWhiteX(x, y); xend = getNextWhiteX(x, y); break; default: break; } if (x < 0) break; int sortLength = xend-x; color[] unsorted = new color[sortLength]; color[] sorted = new color[sortLength]; for (int i=0; i= renderer.width) return -1; } return x; } int getNextBlackX(int _x, int _y) { int x = _x+1; int y = _y; color c; while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) { x++; if (x >= renderer.width) return renderer.width-1; } return x-1; } //BRIGHTNESS int getFirstBrightX(int _x, int _y) { int x = _x; int y = _y; color c; while (brightness (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) { x++; if (x >= renderer.width) return -1; } return x; } int getNextDarkX(int _x, int _y) { int x = _x+1; int y = _y; color c; while (brightness (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) { x++; if (x >= renderer.width) return renderer.width-1; } return x-1; } //WHITE int getFirstNotWhiteX(int _x, int _y) { int x = _x; int y = _y; color c; while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) { x++; if (x >= renderer.width) return -1; } return x; } int getNextWhiteX(int _x, int _y) { int x = _x+1; int y = _y; color c; while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) { x++; if (x >= renderer.width) return renderer.width-1; } return x-1; } //BLACK int getFirstNotBlackY(int _x, int _y) { int x = _x; int y = _y; color c; if (y < renderer.height) { while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) { y++; if (y >= renderer.height) return -1; } } return y; } int getNextBlackY(int _x, int _y) { int x = _x; int y = _y+1; color c; if (y < renderer.height) { while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) { y++; if (y >= renderer.height) return renderer.height-1; } } return y-1; } //BRIGHTNESS int getFirstBrightY(int _x, int _y) { int x = _x; int y = _y; color c; if (y < renderer.height) { while (brightness (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) { y++; if (y >= renderer.height) return -1; } } return y; } int getNextDarkY(int _x, int _y) { int x = _x; int y = _y+1; color c; if (y < renderer.height) { while (brightness (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) { y++; if (y >= renderer.height) return renderer.height-1; } } return y-1; } //WHITE int getFirstNotWhiteY(int _x, int _y) { int x = _x; int y = _y; color c; if (y < renderer.height) { while ( (c = renderer.pixels[x + y * renderer.width]) > params.get(0).value) { y++; if (y >= renderer.height) return -1; } } return y; } int getNextWhiteY(int _x, int _y) { int x = _x; int y = _y+1; color c; if (y < renderer.height) { while ( (c = renderer.pixels[x + y * renderer.width]) < params.get(0).value) { y++; if (y >= renderer.height) return renderer.height-1; } } return y-1; } } /* DISTORTER */ 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; final static int GREEN = 1; final static int BLUE = 2; final static int HUE = 3; final static int SATURATION = 4; final static int BRIGHTNESS = 5; final static int NRED = 6; final static int NGREEN = 7; final static int NBLUE = 8; final static int NHUE = 9; final static int NSATURATION = 10; final static int NBRIGHTNESS = 11; void apply() { buffer = renderer.get(); buffer.resize(renderer.width, renderer.height); 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; y5?channel-6:channel; float cc; switch(ch) { case RED: cc = red(c); break; case GREEN: cc = green(c); break; case BLUE: cc = blue(c); break; case HUE: cc = hue(c); break; case SATURATION: cc = saturation(c); break; default: cc= brightness(c); break; } return channel>5?255-cc:cc; } }