|
|
@@ -1,6 +1,7 @@ |
|
|
|
/* |
|
|
|
|
|
|
|
ASDFPIXELSORT |
|
|
|
by Kim Asendorf |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
@@ -287,6 +288,7 @@ class ASDFPIXELSORT extends Shader { |
|
|
|
/* |
|
|
|
|
|
|
|
DISTORTER |
|
|
|
by Tomasz Sulej |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
@@ -4139,7 +4141,7 @@ class SEGMENTER extends Shader { |
|
|
|
canvas.beginDraw(); |
|
|
|
|
|
|
|
for (int i = 0; i < iterations; i++) { |
|
|
|
canvas.loadPixels(); |
|
|
|
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)); |
|
|
@@ -4224,7 +4226,7 @@ class SEGMENTER extends Shader { |
|
|
|
}//choice |
|
|
|
}//hori loop |
|
|
|
}//vert loop |
|
|
|
canvas.updatePixels(); |
|
|
|
canvas.updatePixels(); |
|
|
|
}//iterations |
|
|
|
canvas.endDraw(); |
|
|
|
} |
|
|
@@ -4237,3 +4239,117 @@ class SEGMENTER extends Shader { |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
COLORCRUSHER |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
class COLORCRUSHER extends Shader { |
|
|
|
float c; |
|
|
|
int m = 5; |
|
|
|
COLORCRUSHER() { |
|
|
|
name = "fxColorCrusher"; |
|
|
|
params.add(new Param("multiplier", INTVAL, 2, 10, new int[]{SINE, TAN, SAWTOOTH, TRIANG})); |
|
|
|
} |
|
|
|
void apply() { |
|
|
|
m = (int)params.get(0).value; |
|
|
|
canvas.beginDraw(); |
|
|
|
canvas.loadPixels(); |
|
|
|
for (int i = 0; i < canvas.pixels.length; i++) { |
|
|
|
c = color(canvas.pixels[i]); |
|
|
|
canvas.pixels[i] = int(c*m); |
|
|
|
} |
|
|
|
canvas.updatePixels(); |
|
|
|
canvas.endDraw(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
RAINBOWHUE |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
//... |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
JPGHexGlitch |
|
|
|
by Victor Giers |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
class JPGHEXGLITCH extends Shader { |
|
|
|
PImage img; |
|
|
|
byte[] brokenfile; |
|
|
|
JPGHEXGLITCH() { |
|
|
|
name = "fxJPGHexGlitch"; |
|
|
|
params.add(new Param("byte amount to change probability", INTVAL, 2, 20, new int[]{RANDOM})); |
|
|
|
params.add(new Param("iterations", INTVAL, 1, 10, new int[]{RANDOM})); |
|
|
|
params.add(new Param("direction", INTVAL, 0, 3, new int[]{RANDOM})); |
|
|
|
directionParamIndex = 2; |
|
|
|
rw = canvas.width; |
|
|
|
rh = canvas.height; |
|
|
|
img = createImage(rw, rh, ARGB); |
|
|
|
} |
|
|
|
int rw, rh; |
|
|
|
void apply() { |
|
|
|
if (rw != canvas.width || rh != canvas.height) { |
|
|
|
rw = canvas.width; |
|
|
|
rh = canvas.height; |
|
|
|
img.resize(rw, rh); |
|
|
|
} |
|
|
|
int probparam = (int)params.get(0).value; |
|
|
|
int iterations = (int)params.get(1).value; |
|
|
|
img = canvas.get(); |
|
|
|
canvas.beginDraw(); |
|
|
|
for (int k = 0; k < iterations; k++) { |
|
|
|
canvas.image(img, canvas.width/2, canvas.height/2); |
|
|
|
canvas.save(dataPath("")+"/JPGHex.jpg"); //save as jpg |
|
|
|
brokenfile = loadBytes(dataPath("")+"/JPGHex.jpg"); //and reload. just in case it wasnt a jpg. |
|
|
|
double probability = float(probparam) / float(brokenfile.length); |
|
|
|
byte[] savebytes2 = new byte[brokenfile.length]; |
|
|
|
boolean headerEnd = false; |
|
|
|
boolean FFfound = false; |
|
|
|
int glitchCount = 0; |
|
|
|
|
|
|
|
for (int i = 0; i < brokenfile.length; i++) { |
|
|
|
String hexStr = hex(brokenfile[i]); |
|
|
|
|
|
|
|
if (FFfound && hexStr.equals("DA")) headerEnd = true; |
|
|
|
FFfound = false; |
|
|
|
if (hexStr.equals("FF")) FFfound = true; |
|
|
|
|
|
|
|
if (headerEnd && random(1)<probability) { |
|
|
|
String randomHex = (str(Character.forDigit((int)random(16), 16)) + str(Character.forDigit((int)random(16), 16))).toUpperCase(); |
|
|
|
hexStr = randomHex; |
|
|
|
glitchCount++; |
|
|
|
} |
|
|
|
byte hexByte[] = fromHexString(hexStr); |
|
|
|
for (int j = 0; j < hexByte.length; j++) { |
|
|
|
savebytes2[i] += hexByte[j]; |
|
|
|
} |
|
|
|
} |
|
|
|
//println("Glitched " + glitchCount + " bytes"); |
|
|
|
saveBytes(dataPath("") + "/result.jpg", savebytes2); |
|
|
|
img = loadImage(dataPath("") + "/result.jpg"); |
|
|
|
} |
|
|
|
|
|
|
|
canvas.endDraw(); |
|
|
|
} |
|
|
|
byte[] fromHexString(final String encoded) { |
|
|
|
if ((encoded.length() % 2) != 0) |
|
|
|
throw new IllegalArgumentException("Input string must contain an even number of characters"); |
|
|
|
|
|
|
|
final byte result[] = new byte[encoded.length()/2]; |
|
|
|
final char enc[] = encoded.toCharArray(); |
|
|
|
for (int i = 0; i < enc.length; i += 2) { |
|
|
|
StringBuilder curr = new StringBuilder(2); |
|
|
|
curr.append(enc[i]).append(enc[i + 1]); |
|
|
|
result[i/2] = (byte) Integer.parseInt(curr.toString(), 16); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |