以陈奕迅照片为基础,通过processing软件实现的随着鼠标的移动,展现出图片的不同动态效果。
PImage eason; int step=3; float startX=0; void setup() { size(800, 800); frameRate(30); strokeWeight(step*1.5); eason=loadImage("eason.jpg"); eason.resize(width, height); eason.loadPixels(); } void draw() { noStroke(); fill(255, 5); rect(0, 0, width, height); startX=mouseX; for (int i=0; i<width; i+=step) { for (int j=0; j<height; j+=step) { int index=i+j*width; color col=eason.pixels[index]; //color col=eason.get(i, j); float xoff=0; float yoff=0; if (i>startX) { float scl=map(i, startX, startX+width, 0, 100); xoff=abs(randomGaussian())*scl; yoff=random(-scl*0.5, scl*0.5); } stroke(col); point(i+xoff, j+yoff); } } }
main=Eason.pde