topical media & game development

talk show tell print

graphic-processing-site-examples-Basics-Math-Noise1D-Noise1D.pde / pde



  
Noise1D. Using 1D Perlin Noise to assign location.

  
   
  float xoff = 0.0;
  float xincrement = 0.01; 
  
  void setup() {
    size(200,200);
    background(0);
    frameRate(30);
    smooth();
    noStroke();
  }
  
  void draw()
  {
    // Create an alpha blended background
    fill(0, 10);
    rect(0,0,width,height);
    
    //float n = random(0,width);  // Try this line instead of noise
    
    // Get a noise value based on xoff and scale it according to the window's width
    float n = noise(xoff)*width;
    
    // With each cycle, increment xoff
    xoff += xincrement;
    
    // Draw the ellipse at the value produced by perlin noise
    fill(200);
    ellipse(n,height/2,16,16);
  }
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.