Created
June 11, 2013 07:45
-
-
Save gregtemp/5755097 to your computer and use it in GitHub Desktop.
Glitch processing patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int[] mPix; | |
int glitch1 = 100; | |
int glitch2 = 10; | |
int rand2 = 10; | |
float size = 75; | |
void setup() { | |
size (displayWidth, displayHeight, OPENGL); | |
mPix = new int[width*height]; | |
hint(ENABLE_NATIVE_FONTS); | |
orientation(LANDSCAPE); | |
} | |
void draw() { | |
background(255); | |
println(frameRate); | |
pushMatrix(); | |
translate(width/2, height/2); | |
fill(0,abs((frameCount%400)-200)/2 + 10); | |
if (mousePressed){ | |
glitchoutRot(); | |
glitchTranslate(); | |
} | |
noStroke(); | |
//stroke(240); | |
// stroke(0, 100); | |
// strokeWeight(2); | |
rotateX(frameCount/70.0); | |
rotateY(frameCount/73.0); | |
rotateZ(frameCount/74.0); | |
box(size); | |
rotateX(frameCount/71.0); | |
rotateY(frameCount/73.0); | |
rotateZ(frameCount/73.0); | |
box(size); | |
rotateX(frameCount/64.0); | |
rotateY(frameCount/67.0); | |
rotateZ(frameCount/61.0); | |
box(size); | |
rotateX(-frameCount/44.0); | |
rotateY(-frameCount/47.0); | |
rotateZ(-frameCount/49.0); | |
if (mousePressed){ | |
box(abs(rand2) * 1.5); | |
} | |
else{ | |
box(size); | |
} | |
popMatrix(); | |
if (mousePressed){ | |
glitchoutPix(); | |
} | |
} | |
void glitchoutRot (){ | |
if (frameCount%glitch1 == 0){ | |
rotateX(random(PI)); | |
rotateY(random(PI)); | |
} | |
if (frameCount%(int(random(20))+1) == 0){ | |
glitch1 = int(random(250) + 50); | |
glitch2 = int(glitch1 / (random(10) + 1)); | |
rand2 = int(random(200) - 100); | |
} | |
} | |
void glitchoutPix (){ | |
loadPixels(); | |
int rand1 = int(random(10) + 1); | |
for (int i = abs(rand2); i < (width*height)/rand1 - abs(rand2); i++) { | |
mPix[i] = pixels[i]; | |
pixels[i*rand1] = mPix[(i*rand1) - rand2]; | |
if (pixels[i] != color(255, 255, 255)){ | |
pixels[i] = color(random(255), random(255), random(255)); | |
} | |
} | |
updatePixels(); | |
} | |
void glitchTranslate(){ | |
translate(-rand2,0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment