Wavy Image


  // Wavy Image - Jim Bumgardner
  
  //   @pjs preload="joy_header.png";
  
  PImage myImage;
  float distortion = 5;  // height of waves
  float movement = .01;  // movement of waves
  float detail = 5;      // tightness of waves
  
  void setup()
  {
    size(275,199);
    myImage = loadImage("/joy_header.png");
  }
  
  void draw()
  {
    background(255);
    for (int i = 0; i < min(width,myImage.width); ++i) {
      int dev = (int) ((sin((millis()+i*detail)*movement)+1)*distortion);
      copy(myImage, i,0,1,height, i, -dev,1,height+dev*2);
    }
  }