/**
* Wormhole Demo Effect
* by luis2048.
*/
PImage wormImg, wormTexture;
int[] reg = new int[15];
void setup(){
size(640,360,P2D);
noSmooth();
//Reference image used to transpose texture
wormImg = loadImage("wormhole.png");
wormImg.resize(width,height);
wormImg.loadPixels();
wormTexture = loadImage("texture.gif");
wormTexture.loadPixels();
}
void shiftup(){
for(int k =0; k < 15; k++){
reg[k] = wormTexture.pixels[k];
}
for(int k = 15; k < 225; k ++){
wormTexture.pixels[k-15] = wormTexture.pixels[k];
}
for(int k =0; k < 15; k++){
wormTexture.pixels[k+210] = reg[k];
}
}
void shiftright(){
for(int k = 0; k < 15; k++){
reg[k] = wormTexture.pixels[15*k+14];
for(int i =14; i > 0; i --){
wormTexture.pixels[15*k+i] = wormTexture.pixels[15*k+(i-1)];
}
wormTexture.pixels[15*k] = reg[k];
}
}
void draw(){
loadPixels();
for(int i =0; i < pixels.length; i++){
pixels[i] = wormTexture.pixels[constrain(wormImg.pixels[i] & 0xFF,0,224)];
}
updatePixels();
shiftright();
shiftup();
}
コメント
コメントを投稿