Ciao 访客, welcome back to old school! :p
int Width = 800;int Height = 600;int FullSize = 0;int Spacing = 10;int[] source, dest;PImage bg;void setup(){ bg = loadImage("terminator_2.jpg"); Width = bg.width; Height = bg.height; FullSize = Width * Height; size(Width, Height); source = new int[FullSize]; dest = new int[FullSize]; for (int i=0; i< FullSize; i++) source[i] = dest[i] = 0;}void draw(){ if (mousePressed) { if (mouseX > 0 && mouseX < Width && mouseY > 0 && mouseY < Height) source[mouseY*Width+mouseX] = (int)random(100, 5000); } for (int i=Width; i< FullSize-Width; i++) { // check for bounds int xi = i % Width; if ((xi==0) || (xi==Width-1)) continue; dest[i] = ( ((source[i-1]+ source[i+1]+ source[i-Width]+ source[i+Width]) >>1) ) -dest[i]; dest[i] -= (dest[i] >> 5); // Damping - Quick divde by 32 (5 bits) } //image(bg, 0, 0); loadPixels(); for (int i=Width; i< FullSize-Width; i++) { // check for bounds int xi = i % Width; if ((xi==0) || (xi==Width-1)) continue; int xoffset = dest[i-1] - dest[i+1]; int yoffset = dest[i-Width] - dest[i+Width]; int offset = i+xoffset+yoffset*Width; if (offset>0 && offset<FullSize) pixels[i] = bg.pixels[offset]; } //bg.updatePixels(); updatePixels(); //swap int[] temp = source; source = dest; dest = temp;}
那个我是新手,就是这个程序我试的时候是显示出错的。。不懂所以想问下。。谢谢啊