• fullscreen
  • PerlinArt.pde
  • int WIDTH;
    int HEIGHT;
    
    ArrayList particles;
    Particle tempParticle;
    color leftColor;//Color for the left of the screen
    color rightColor;//Color for the right of the screen
    color particleColor;//Color lerped from leftColor and rightColor
    long timer = 10;//How long until auto restart
    long lastTime = 0;//Used with timer
    
    void setup()
    {
      size(800, 600, P2D);
      WIDTH = 800;
      HEIGHT = 600;
      frameRate(500);
      smooth();
      restart();
    }
    
    void restart()
    {
      particles = new ArrayList();
      leftColor = color(random(255), random(255), random(255));
      rightColor = color(random(255), random(255), random(255));
      for(int i = 0; i < 3000; i++)
      {
        particleColor = lerpColor(leftColor, rightColor, float(i) / WIDTH);
        particles.add(new Particle(random(0, WIDTH), random(0, HEIGHT), particleColor));
      }
      noiseSeed(second());//Creates a new noise pattern
      background(0);
    }
    
    void draw()
    {
      for(int i = 0; i < particles.size(); i++)
      {
        tempParticle = (Particle) particles.get(i);
        tempParticle.update();
        tempParticle.drawPoint();
      }
      
      if(second() - lastTime >= timer)
      {
        lastTime = second();
        restart();
      }
    }
    
    void mouseReleased()
    {
      lastTime = second();
        restart();
    }
    
    class Particle
    {
      float posX;
      float posY;
      float r, g, b, a;
      color clr;
      
      protected Particle(float x, float y, color c)
      {
        posX = x;
        posY = y;
        r = red(c);
        g = green(c);
        b = blue(c);
        a = 10;
      }
      
      public void update()
      {
        clr = lerpColor(leftColor, rightColor, (float)posX / WIDTH);
        r = red(clr);
        g = green(clr);
        b = blue(clr);
        posY += sin(noise(posX * 0.01, posY * 0.01) * TWO_PI);
        posX += cos(noise(posX * 0.01, posY * 0.01) * TWO_PI);
        if(posY < 0 || posY > HEIGHT - 1)
        {
          posY = random(0, HEIGHT);
          posX = random(0, WIDTH);
        }
        if(posX < 0 || posX > WIDTH - 1)
        {
          posY = random(0, HEIGHT);
          posX = random(0, WIDTH);
        }
      }
      
      public void drawPoint()
      {
        stroke(r, g, b, a);
        point(posX, posY);
      }
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    CgRobot

    Perlin Art

    Add to Faves Me Likey@! 3
    You must login/register to add this sketch to your favorites.

    Inspired by this sketch http://openprocessing.org/sketch/6707
    I decided to make a visual with perlin noise myself.

    Click to restart with new random colors.
    It will auto restart after 10 seconds. It occasionally glitches and won't restart automatically. I don't know why. Just click and it should be fine.
    Enjoy!

    P.S. I have run this in fullscreen and although it runs slower than normal, it doesn't really lag. I recommend that you try it for yourself.

    francisco lara
    10 Jun 2013
    CgRobot it is possible to export those geometries as dxf from processing?
    do you think you could add that code to it?
    I have been trying to do it myself but I cant really make it work!
    its to complex for me! I dont have much knowldge on processing.
    I made it work with some others codes (simple ones)
    please help me out!
    Thanks
    CgRobot
    10 Jun 2013
    I'm afraid not. There is no geometry in the application, so there is nothing for me to export. All you're seeing is colors painted onto the background by moving particles. If you simply want to save the image, you can use this function:

    http://processing.org/reference/save_.html

    Example:

    void keyReleased()
    {
    save("Perlin Art.png");
    }

    However, if you still would like to know how to save geometry for future projects, take a look at this simple example:

    http://www.processing.org/reference/libraries/dxf/

    I myself have never used that library, but it looks to me like it's what you're after.
    You need to login/register to comment.